1 /*
2  * Copyright (C) 2007-2008 Yann Nicolas Dauphin
3  * Copyright (C) 2007-2008, 2017 Sam Steingold
4  * Copyright (C) 2016-2017 Bruno Handle
5  * This file is a part of GNU CLISP and is distributed under GNU GPL v2+
6  *
7  * These are the set of macros built on top of GNU Lightning
8  * to build the JIT compiler.
9  * Simplicity and predictability is enforced.
10  *
11  * To understand GNU Lightning, have a quick look at the examples in:
12  * http://www.gnu.org/software/lightning/manual/html_node/GNU-lightning-macros.html
13  *
14  * - The macros behave like functions; they may modify JIT_R0 and
15  *   JIT_R1 only (exceptions are identified by the 'x' postfix)
16  *
17  * - Macros ending in 'i' take an immediate value as parameter, a macro
18  *   ending with 'r' takes JIT_R2 as parameter.
19  *   Macros that take an immediate value and register R2 as parameters
20  *   end in 'ir', etc...
21  *
22  *   Macros ending in 'x' are SPECIAL macros. READ THEIR DOCUMENTATION
23  *   before using or code next to them.
24  *
25  * - MACROS can return values in one of two ways:
26  *   - It puts the value in one of it's parameters
27  *   - It stores it in JIT_R0
28  *
29  * Map of the registers:
30  * JIT_R0, JIT_R1, JIT_R2: free usage
31  * JIT_V0:
32  * JIT_V1: Pointer to the closure on the stack(closureptr)
33  * JIT_V2:
34  * Example of use:
35  *
36  * General comments:
37  * If you plan to extend the JIT, you will probably run into
38  *   a GNU lightning's weakness.
39  * It has no integrated debugger.
40  * But it is not a problem if you know and apply the following:
41  *  - Always work in small chunks
42  *  - Always use jitc_debug() to check the generated code
43  *
44  *  - If the code doesn't compile because of 'Cannot apply unary & etc', it's
45  *    because you are passing an immediate value in place of a register
46  *  - Most weird runtime errors are due to passing a immediate value in
47  *    place of a register
48  *
49  * GOTCHAs
50  * - jit_eq*: Always use JIT_R0 as destination value.
51  *            Never use the same register in two operand slots.
52  * TODO:
53  * - Make a smarter algorithm to allocate space for the JITed function
54  */
55 
56 #include <lightning.h>
57 
58 /* Pointer to a JIT-Compiled function */
59 /* Takes the closure and the distance to the starting bytecode as arguments */
60 typedef int (*jitc_func)(object, uintL);
61 
62 /* This is for x86 (Quite imprecise for now) */
63 #define JITC_AVG_BCSIZE 130
64 
65 /* ======= CLISP GC harness */
66 struct jitc_object {
67   int jo_gc_mark;
68   jit_insn *code_buffer;
69   jit_insn **bc_index;
70   struct jitc_object* jo_next;
71 };
72 /* all JITC objects as a linked list */
73 static struct jitc_object *all_jitc_objects = NULL;
74 bool gc_drop_jitc = false;
75 /* mark object as used */
gc_mark_jitc_object(void * ptr)76 void gc_mark_jitc_object (void *ptr) {
77   struct jitc_object *jo = (struct jitc_object*)ptr;
78   jo->jo_gc_mark = 1;
79 }
80 /* scan all JITC objects and release unused objects */
gc_scan_jitc_objects(void)81 void gc_scan_jitc_objects (void) {
82   struct jitc_object **next = &all_jitc_objects;
83   while (*next) {
84     if ((*next)->jo_gc_mark) {  /* keep */
85       (*next)->jo_gc_mark = 0;  /* unmark for the next GC */
86       next = &((*next)->jo_next);
87     } else {                      /* release */
88       struct jitc_object *jo_next = (*next)->jo_next;
89       free((*next)->code_buffer);
90       free((*next)->bc_index);
91       free(*next);
92       *next = jo_next;
93     }
94   }
95 }
96 /* ------------------- (*) JIT Internals ----------------------- */
97 /* Check overflow on codebuffer */
98 #define jitc_check_overflow()\
99     if((jit_insn*)jit_get_ip().ptr > (codeBuffer + (sizeof(jit_insn)*byteptr_max*JITC_AVG_BCSIZE))){\
100         fprint(stderr,"\nFATAL ERROR: JIT codeBuffer overflow\n");\
101         exit(-1);\
102     }
103 /* jitc_patch_fwdjmps():
104 All values in bcIndex are initialized to 0(by calloc).
105 If the value bcIndex[bcPos] is different from 0, it means there are forward
106 jumps to this bytecode(see jitc_bcjmpi()).
107 Forward jumps are stored as a list. See jitc_bcjmpi(bc).
108 This implies that (bcPos == byteptr - CODEPTR).*/
109 struct jitc_insn_list {
110   jit_insn* jump;
111   struct jitc_insn_list* next;
112 };
113 #define jitc_patch_fwdjmps()   \
114   if(bcIndex[bcPos]){          \
115     struct jitc_insn_list *list = (struct jitc_insn_list*)bcIndex[bcPos];\
116     while (list != NULL) {         \
117       jit_insn *ref = list->jump;  \
118       jit_patch(ref);              \
119       struct jitc_insn_list *prev = list;  \
120       list = list->next;                   \
121       free(prev);                          \
122     }                                      \
123   }
124 
125 /* jitc_bcjmpi(bc):
126  Puts a jump to bytecode bc.
127  If it's a back jump, just patch it.
128  If it's a forward jump, put a list in the bcIndex[bc] with the address
129  to be patched. */
130 #define jitc_bcjmpi(bc) do {       \
131   jit_insn* rf1;                   \
132   rf1 = jit_jmpi(jit_forward());   \
133   if ((bc) < (byteptr - CODEPTR)) { /* BACK JMP */\
134     jit_insn *rf2 = bcIndex[bc]; \
135     jit_patch_at ((rf1), (rf2)); \
136   } else if (bcIndex[bc] == 0) { /* FWD JMP: no list for this BC */\
137     struct jitc_insn_list *list = malloc(sizeof(struct jitc_insn_list));\
138     list->jump = rf1;  \
139     list->next = NULL; \
140     bcIndex[bc] = (jit_insn*)list;\
141   } else{ /* FWD JMP: add to list */\
142     struct jitc_insn_list *new_cell = malloc(sizeof(struct jitc_insn_list));\
143     new_cell->jump = rf1;  \
144     new_cell->next = (struct jitc_insn_list*)bcIndex[bc]; \
145     bcIndex[bc] = (jit_insn*)new_cell;\
146   }  \
147 } while(0)
148 /* Uses addresses in bcIndex to jmp */
149 #define jitc_bcjmpr();\
150     jit_muli_ul(JIT_R1,JIT_R2,sizeof(jit_insn*));\
151     jit_movi_p(JIT_R0,bcIndex);\
152     jit_ldxr_p(JIT_R0,JIT_R0,JIT_R1);\
153     jit_jmpr(JIT_R0);
154 
155 #define jitc_return() jit_ret();
156 
157 /* All bytecodes that modify the runtime context of a JIT function are tagged
158 with jitc_tag_unsafe. This eases the task of assigning a register to a permanent value*/
159 #define jitc_tag_unsafe()
160 /* ------------------- (0) Utilities ----------------------- */
161 /* this file is not processed by clisp/src/po/clisp-xgettext
162    because all error messages that appear in this file already appear in
163    src/eval.d, so we can use GETTEXT in this macro */
164 #define jitc_errori(type, message)               \
165   jit_movi_l(JIT_R0, type);                     \
166   jit_movi_p(JIT_R1, GETTEXT(message));         \
167   jit_prepare(2);                               \
168   jit_pusharg_p(JIT_R1);                        \
169   jit_pusharg_p(JIT_R0);                        \
170   jit_finish(error)
171 #define jitc_notreached()                        \
172   jit_prepare(2);                               \
173   jit_movi_l(JIT_R0,__LINE__);                  \
174   jit_pusharg_p(JIT_R0);                        \
175   jit_movi_p(JIT_R0,__FILE__);                  \
176   jit_pusharg_p(JIT_R0);                        \
177   jit_finish(error_notreached)
178 
179 /* Gives access to slots in structures */
180 #define jitc_get_fieldr(type, field)\
181     jit_ldxi_p(JIT_R0, JIT_R2, The##type(as_object(jit_ptr_field(type, field))));
182 #define jitc_getptr_fieldr(type, field)\
183     jit_addi_p(JIT_R0, JIT_R2, The##type(as_object(jit_ptr_field(type, field))));
184 
185 /* Length of a srecord */
186 #define jitc_getlenr(type)\
187     jitc_get_fieldr(type,tfl);\
188     jit_rshi_ul(JIT_R0,JIT_R0,16);
189 
190 /* Gives access to a closure's constants */
191 #define jitc_get_cconsti(n)\
192     jit_ldr_p(JIT_R0,JIT_V1);\
193     jit_addi_p(JIT_R0, JIT_R0, TheCclosure(as_object(jit_ptr_field(Cclosure, clos_consts))));\
194     jit_ldxi_p(JIT_R0,JIT_R0,(n)*sizeof(gcv_object_t));
195 #define jitc_getptr_cconsti(n)\
196     jit_ldr_p(JIT_R0,JIT_V1);\
197     jit_addi_p(JIT_R0, JIT_R0, TheCclosure(as_object(jit_ptr_field(Cclosure, clos_consts))));\
198     jit_addi_p(JIT_R0,JIT_R0,(n)*sizeof(gcv_object_t));
199 
200 /* jitc_repeat():
201  > reg: counter
202  > STATEMENT:
203  Checks if (reg == 0) before looping */
204 #define jitc_repeat(reg, STATEMENT)              \
205   {           jit_insn *rf166,*rf266;           \
206     rf166 = jit_beqi_p(jit_forward(),reg,0);    \
207     rf266 = jit_get_label();                    \
208                                                 \
209     STATEMENT;                                  \
210                                                 \
211     jit_subi_p(reg,reg,1);                      \
212     jit_bnei_p(rf266,reg,0);                    \
213     jit_patch(rf166);                           \
214   }
215 /* jitc_repeatp():
216  > reg: counter
217  > STATEMENT:
218  Does not check (if reg == 0) before looping */
219 #define jitc_repeatp(reg, STATEMENT)\
220 {           jit_insn *ref66;\
221 ref66 = jit_get_label();\
222             \
223             STATEMENT;\
224             \
225             jit_subi_p(reg,reg,1);\
226 jit_bnei_p(ref66,reg,0);\
227     }
228 /* ------------------- (1) Stack operations ----------------------- */
229 #ifdef ONE_FREE_BIT_HEAPCODES
230     /* jitc_getsize_framer(): */
231     /* > &bottomword: Address of bottomword */
232     #define jitc_getsize_framer()\
233         jit_ldr_ui(JIT_R1,JIT_R2);\
234         jit_andi_ui(JIT_R0,JIT_R1,(wbit(FB1)-1));
235     #define jitc_get_framecoder()\
236         jit_andi_ui(JIT_R0,JIT_R2,minus_wbit(FB1));
237 #endif
238 #if defined(KERNELVOID32_HEAPCODES) || defined(GENERIC64_HEAPCODES)
239     /* jitc_getsize_framer(): */
240     /* > &bottomword: Address of bottomword */
241     #define jitc_getsize_framer()\
242         jit_ldr_ui(JIT_R1,JIT_R2);\
243         jit_rshi_ul(JIT_R0,JIT_R1,6);
244     #define jitc_get_framecoder()\
245         jit_andi_ui(JIT_R0,JIT_R2,0x3F);
246 #endif
247 #ifdef STACK_DOWN
248     #define jitc_bnov_stacki jit_blti_p
249     #define jitc_getptbl_stackr()
250   #define jitc_skip_stack_opir jit_addi_p
251     #define jitc_skip_stack_opr jit_addr_p
252     #define jitc_get_stacki(n)\
253         jit_ldi_p(JIT_R1, &STACK);\
254         jit_ldxi_i(JIT_R0, JIT_R1,(n)*sizeof(gcv_object_t));
255     #define jitc_getptr_stacki(n)\
256         jit_ldi_p(JIT_R1, &STACK);\
257         jit_addi_i(JIT_R0, JIT_R1,(n)*sizeof(gcv_object_t));
258     #define jitc_get_framei(n)\
259         jit_ldxi_p(JIT_R0,JIT_R2,(n)*sizeof(gcv_object_t));
260     #define jitc_getptr_framei(n)\
261         jit_addi_p(JIT_R0,JIT_R2,(n)*sizeof(gcv_object_t));
262     /* jitc_gettop_framer(): */
263     /* > &bottomword: Address of bottomword */
264     #define jitc_gettop_framer()\
265         jitc_getsize_framer();\
266         jit_addr_ui(JIT_R1,JIT_R2,JIT_R0);\
267         jit_movr_p(JIT_R0,JIT_R1);
268     /* reg is modified */
269     #define jitc_frame_nextx(reg)\
270         jit_subi_p(reg,reg,sizeof(gcv_object_t));\
271         jit_ldr_p(JIT_R0,reg);
272     #define jitc_get_scountr(res,new,old)\
273         jit_subr_p(res,old,new);\
274         jit_divi_ul(res,res,sizeof(void*));
275 #endif
276 #ifdef STACK_UP
277     #define jitc_bnov_stacki jit_bgti_p
278     #define jitc_getptbl_stackr()  jit_subi_i(JIT_R0,JIT_R2,sizeof(gcv_object_t))
279   #define jitc_skip_stack_opir jit_subi_p
280     #define jitc_skip_stack_opr jit_subr_p
281     #define jitc_get_stacki(n)\
282         jit_ldi_p(JIT_R1, &STACK);\
283         jit_ldxi_i(JIT_R0, JIT_R1,-sizeof(gcv_object_t) - ((n)*sizeof(gcv_object_t)));
284     #define jitc_get_stackr()\
285         jit_ldi_p(JIT_R1, &STACK);\
286         jit_subi_p(JIT_R1,JIT_R1,sizeof(gcv_object_t));\
287         jit_muli_ul(JIT_R0,JIT_R2,sizeof(gcv_object_t));\
288         jit_subr_p(JIT_R1,JIT_R1,JIT_R0);\
289         jit_ldr_p(JIT_R0, JIT_R1);
290     #define jitc_getptr_stacki(n)\
291         jit_ldi_p(JIT_R1, &STACK);\
292         jit_addi_i(JIT_R0, JIT_R1,-sizeof(gcv_object_t) - ((n)*sizeof(gcv_object_t)));
293     #define jitc_get_framei(n)\
294         jit_ldxi_i(JIT_R0, JIT_R2,-sizeof(gcv_object_t) - ((n)*sizeof(gcv_object_t)));
295     #define jitc_getptr_framei(n)\
296         jit_addi_i(JIT_R0, JIT_R2,-sizeof(gcv_object_t) - ((n)*sizeof(gcv_object_t)));
297     /* jitc_gettop_framer(): */
298     /* > &bottomword: Address of bottomword */
299     #define jitc_gettop_framer()\
300         jitc_getsize_framer();\
301         jit_subr_ui(JIT_R1,JIT_R2,JIT_R0);\
302         jit_addi_ui(JIT_R0,JIT_R1,sizeof(gcv_object_t));
303     /* reg is modified */
304     #define jitc_frame_nextx(reg)\
305         jit_ldr_p(JIT_R0,reg);\
306         jit_addi_p(reg,reg,sizeof(gcv_object_t));
307     #define jitc_get_scountr(res,new,old)\
308         jit_subr_p(res,new,old);\
309         jit_divi_ul(res,res,sizeof(void*));
310 #endif
311 
312 
313 #define jitc_skip_stacki(n)\
314     jit_ldi_p(JIT_R0, &STACK);\
315     jitc_skip_stack_opir(JIT_R0, JIT_R0,(n)*sizeof(gcv_object_t));\
316     jit_sti_p(&STACK, JIT_R0);
317 #define jitc_skip_stackr()\
318     jit_ldi_p(JIT_R0, &STACK);\
319     jit_muli_i(JIT_R1,JIT_R2,sizeof(void*));\
320     jitc_skip_stack_opr(JIT_R0, JIT_R0,JIT_R1);\
321     jit_sti_p(&STACK, JIT_R0);
322 
323 #define jitc_push_stacki(obj)\
324     jitc_getptr_stacki(-1);\
325     jit_movi_l(JIT_R1, obj);\
326     jit_str_p(JIT_R0, JIT_R1);\
327     jitc_skip_stacki(-1);
328 #define jitc_push_stackr()\
329     jitc_getptr_stacki(-1);\
330     jit_str_p(JIT_R0, JIT_R2);\
331     jitc_skip_stacki(-1);
332 /* Loads the argument before pushing */
333 #define jitc_ldpush_stackr()\
334     jitc_getptr_stacki(-1);\
335     jit_ldr_p(JIT_R1,JIT_R2);\
336     jit_str_p(JIT_R0, JIT_R1);\
337     jitc_skip_stacki(-1);
338 
339 #define jitc_pop_stack()\
340     jitc_skip_stacki(1);\
341     jitc_get_stacki(-1);
342 
343 /*  Make the 'Frame Info' word of a frame on the lisp stack */
344 #define jitc_finish_framer(TYPE, SIZE)\
345     jitc_getptr_stacki(-1);\
346     jit_movi_l(JIT_R1,as_oint(makebottomword(TYPE##_frame_info,SIZE*sizeof(gcv_object_t))));\
347     jit_str_p(JIT_R0, JIT_R1);\
348     jitc_skip_stacki(-1);
349 
350 /* Check if the stack has overflowed */
351 #define jitc_check_stack()\
352     { jit_insn* ref;\
353         jit_ldi_p(JIT_R0,&(STACK));\
354         jit_ldi_p(JIT_R1,&(STACK_bound));\
355     ref = jitc_bnov_stacki(jit_forward(), JIT_R0,JIT_R1);\
356         (void)jit_calli(STACK_ueber);\
357     jit_patch(ref);\
358     }
359 /* jitc_check_stack i-r():
360  Check if the stack will overflow given the parameter
361  Equivalent to macro get_space_on_STACK */
362 #define jitc_check_stackr()\
363     { jit_insn* ref;\
364         jit_ldi_p(JIT_R0,&(STACK));\
365         jit_ldi_p(JIT_R1,&(STACK_bound));\
366         jit_addr_p(JIT_R1,JIT_R1,JIT_R2);\
367     ref = jitc_bnov_stacki(jit_forward(), JIT_R0,JIT_R1);\
368         (void)jit_calli(STACK_ueber);\
369     jit_patch(ref);\
370     }
371 #define jitc_check_stacki(n)\
372     { jit_insn* ref;\
373         jit_ldi_p(JIT_R0,&(STACK));\
374         jit_ldi_p(JIT_R1,&(STACK_bound));\
375         jit_addi_p(JIT_R1,JIT_R1,(n));\
376     ref = jitc_bnov_stacki(jit_forward(), JIT_R0,JIT_R1);\
377         (void)jit_calli(STACK_ueber);\
378     jit_patch(ref);\
379     }
380 /* ------------------- (2) Multiple Values ----------------------- */
381 /* jitc_rawset_valuesi_1: */
382 /* Doesn't modify mvcount */
383 #define jitc_rawset_valuesi_1(value)\
384     jit_movi_l(JIT_R0, value);\
385     jit_sti_p (mv_space,JIT_R0);
386 
387 #define jitc_set_valuesi_1(value)\
388     jit_movi_l(JIT_R0, value);\
389     jit_sti_p(mv_space,JIT_R0);\
390     jit_movi_ui(JIT_R0, 1);\
391     jit_sti_ui(&mv_count, JIT_R0);
392 #define jitc_set_valuesr_1()\
393     jit_sti_p (mv_space,JIT_R2);\
394     jit_movi_ui(JIT_R0, 1);\
395     jit_sti_ui(&mv_count, JIT_R0);
396 #define  jit_set_valuesi(N,value) \
397     jit_movi_ui(JIT_R0,N);\
398     stxi_p(mv_space,N,value); \
399     jit_movi_ui(JIT_R0, N);\
400     jit_sti_ui(&mv_count, JIT_R0);
401 
402 #define jitc_get_valuesr_1()\
403     jit_ldi_p(JIT_R0, mv_space);
404 #define jitc_getptr_valuesr_1()\
405     jit_movi_l(JIT_R0, mv_space);
406 
407 #define jitc_getptr_valuesi(n)\
408     jit_movi_l(JIT_R0, mv_space);\
409     jit_addi_p(JIT_R0,JIT_R0,(n)*sizeof(gcv_object_t));
410 #define jitc_getptr_valuesr()\
411     jit_movi_l(JIT_R0, mv_space);\
412     jit_muli_ul(JIT_R1,JIT_R2,sizeof(gcv_object_t));\
413     jit_addr_p(JIT_R0,JIT_R0,JIT_R1);
414 
415 #define jitc_get_mvcountr()\
416     jit_ldi_p(JIT_R0, &mv_count);
417 #define jitc_set_mvcounti(n)\
418     jit_movi_ui(JIT_R0,n);\
419     jit_sti_p(&mv_count,JIT_R0);
420 #define jitc_set_mvcountr()\
421     jit_sti_p(&mv_count,JIT_R2);
422 /* Modifies All registers except JIT_V0 */
423 #define jitc_mv2stackx()\
424     {       jit_insn *rf1,*rf2;\
425             jitc_get_mvcountr();\
426 rf1 = jit_beqi_p(jit_forward(),JIT_R0,0);\
427 \
428             jit_movr_p(JIT_V2,JIT_R0);\
429             jit_movr_p(JIT_R2,JIT_R0);\
430             jitc_check_stackr();\
431             jitc_getptr_valuesi(0);\
432             jit_movr_p(JIT_V1,JIT_R0);\
433 jitc_repeatp(JIT_V2,\
434             jit_ldr_p(JIT_R2,JIT_V1);\
435             jitc_push_stackr();\
436             jit_addi_p(JIT_V1,JIT_V1,sizeof(gcv_object_t));\
437 );\
438 \
439 jit_patch(rf1);\
440     }
441 /* ------------------- (3) SP operations ----------------------- */
442 /* Operations on a down-growing stack */
443 #define jitc_set_spr()\
444     jit_stxi_p(jitc_sp_ptr,JIT_FP, JIT_R2);
445 #define jitc_get_spi(n)\
446     jit_ldxi_p(JIT_R1,JIT_FP,jitc_sp_ptr);\
447     jit_ldxi_p(JIT_R0, JIT_R1, (n)*sizeof(SPint));
448 #define jitc_getptr_spi(n)\
449     jit_ldxi_p(JIT_R1,JIT_FP,jitc_sp_ptr);\
450     jit_addi_p(JIT_R0, JIT_R1, (n)*sizeof(SPint));
451 
452 #define jitc_skip_spi(n)\
453     jit_ldxi_p(JIT_R1,JIT_FP,jitc_sp_ptr);\
454     jit_addi_p(JIT_R0,JIT_R1,(n)*sizeof(SPint));\
455     jit_stxi_p(jitc_sp_ptr,JIT_FP, JIT_R0);
456 
457 #define jitc_push_spi(item)\
458     jitc_getptr_spi(-1);\
459     jit_stxi_p(jitc_sp_ptr,JIT_FP, JIT_R0);\
460     jit_movi_l(JIT_R1, (item));\
461     jit_str_p(JIT_R0,JIT_R1);
462 #define jitc_push_spr()\
463     jitc_getptr_spi(-1);\
464     jit_stxi_p(jitc_sp_ptr,JIT_FP, JIT_R0);\
465     jit_str_p(JIT_R0,JIT_R2);
466 /* Loads the parameter before pushing */
467 #define jitc_ldpush_spr()\
468     jitc_getptr_spi(-1);\
469     jit_stxi_p(jitc_sp_ptr,JIT_FP, JIT_R0);\
470     jit_ldr_p(JIT_R1,JIT_R2);\
471     jit_str_p(JIT_R0,JIT_R1);
472 
473 #define jitc_pop_sp()\
474     jitc_getptr_spi(0);\
475     jit_addi_p(JIT_R1,JIT_R0,sizeof(SPint));\
476     jit_stxi_p(jitc_sp_ptr,JIT_FP, JIT_R1);\
477     jit_ldr_p(JIT_R0, JIT_R0);
478 #define jitc_alloc_jmpbuf()\
479     jit_ldxi_p(JIT_R0,JIT_FP,jitc_sp_ptr);\
480     jit_subi_i(JIT_R0,JIT_R0,(jmpbufsize)*sizeof(SPint));\
481     jit_stxi_p(jitc_sp_ptr,JIT_FP, JIT_R0);
482 #define jitc_free_jmpbuf()\
483     jit_ldxi_p(JIT_R0,JIT_FP,jitc_sp_ptr);\
484     jit_addi_i(JIT_R0,JIT_R0,(jmpbufsize)*sizeof(SPint));\
485     jit_stxi_p(jitc_sp_ptr,JIT_FP, JIT_R0);
486 #define jitc_finish_eframex(TYPE, SIZE, ON_REENTRY, ON_FINISH)\
487 {\
488         jit_insn *rf1;\
489         jitc_push_stackr();\
490         jitc_push_stacki(as_oint(nullobj));\
491         \
492         jit_prepare(1);\
493         jit_pusharg_p(JIT_R2);\
494         jit_finish(setjmp);\
495         jit_retval(JIT_R2);\
496         \
497 rf1 = jit_beqi_p(jit_forward(),JIT_R2,0);\
498         jitc_set_spr();\
499         \
500         ON_REENTRY;\
501         \
502 jit_patch(rf1);\
503         jitc_getptr_stacki(0);\
504         jit_movi_l(JIT_R1,as_oint(makebottomword(TYPE##_frame_info,SIZE*sizeof(gcv_object_t))));\
505         jit_str_p(JIT_R0,JIT_R1);\
506         \
507         ON_FINISH;\
508 }
509 
510 
511 /* ------------------- (4) Symbols ----------------------- */
512 #define jitc_get_symvali(symbol)\
513     jit_movi_l(JIT_R1,symbol);\
514     jit_ldxi_p(JIT_R0,JIT_R1, TheSymbol(as_object(jit_ptr_field(Symbol, symvalue))));
515 #define jitc_get_symvalr()\
516     jit_ldxi_p(JIT_R0,JIT_R2, TheSymbol(as_object(jit_ptr_field(Symbol, symvalue))));
517 #define jitc_getptr_symvali(symbol)\
518     jit_movi_l(JIT_R1,symbol);\
519     jit_addi_p(JIT_R0,JIT_R1, TheSymbol(as_object(jit_ptr_field(Symbol, symvalue))));
520 #define jitc_getptr_symvalr()\
521     jit_addi_p(JIT_R0,JIT_R2, TheSymbol(as_object(jit_ptr_field(Symbol, symvalue))));
522 #define jitc_sym_constpr(sym)\
523     jit_ldxi_p(JIT_R0, JIT_R2, TheSymbol(as_object(jit_ptr_field(Symbol, header_flags))));\
524     jit_notr_ul(JIT_R0,JIT_R0);\
525     jit_andi_ul(JIT_R1,JIT_R0,bit(var_bit0_hf)|bit(var_bit1_hf));\
526     jit_eqi_ul(JIT_R0,JIT_R1,0);
527 
528 #define jitc_sympr()\
529   { jit_insn* ref;                                                      \
530     jit_andi_ul(JIT_R1, JIT_R2,nonimmediate_heapcode_mask);             \
531     jit_movi_l(JIT_R0,0);                                               \
532     ref = jit_bnei_p(jit_forward(),JIT_R1,(varobject_bias+varobjects_misaligned)); \
533     jit_ldxi_p(JIT_R1,JIT_R2, TheRecord(as_object(jit_ptr_field(Record, tfl))));   \
534     jit_andi_ul(JIT_R1, JIT_R1,0xFF);                                   \
535     jit_eqi_p(JIT_R0,JIT_R1,Rectype_Symbol);                            \
536     jit_patch(ref);}
537 
538 /* Modifies JIT_R2 */
539 #define jitc_check_fdefx() {                                             \
540     jit_insn *rf1,*rf2;                                                 \
541     jitc_sympr();                                                        \
542     rf1 = jit_beqi_p(jit_forward(),JIT_R0,1);                           \
543     jitc_save_backtrace3(as_oint(L(symbol_function)), STACK, -1, -1,{    \
544         jit_prepare(1);                                                 \
545         jit_pusharg_p(JIT_R2);                                          \
546         jit_finish(check_symbol);                                       \
547         jit_retval(JIT_R2);                                             \
548       });                                                               \
549     jit_patch(rf1);                                                     \
550     jitc_get_fieldr(Symbol,symfunction);                                 \
551     rf2 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(unbound));            \
552     jit_prepare(2);                                                     \
553     jit_movi_l(JIT_R0,as_oint(S(symbol_function)));                     \
554     jit_pusharg_p(JIT_R0);                                              \
555     jit_pusharg_p(JIT_R2);                                              \
556     jit_finish(check_fdefinition);                                      \
557     jit_retval(JIT_R0);                                                 \
558     jit_patch(rf2);                                                     \
559   }
560 
561 #define jitc_sym_atompr()\
562     jit_andi_ul(JIT_R1,JIT_R2,7);\
563     jit_nei_p(JIT_R0,JIT_R1,(cons_bias+conses_misaligned));
564 #define jitc_sym_conspr()\
565     jit_andi_ul(JIT_R1,JIT_R2,7);\
566     jit_eqi_p(JIT_R0,JIT_R1,(cons_bias+conses_misaligned));
567 /* ------------------- (5) Svectors ----------------------- */
568 #define jitc_svecpr()\
569         { jit_insn* ref;\
570     jit_andi_ul(JIT_R1, JIT_R2,nonimmediate_heapcode_mask);\
571                 jit_movi_l(JIT_R0,0);\
572 ref = jit_bnei_p(jit_forward(),JIT_R1,(varobject_bias+varobjects_misaligned));\
573     jit_ldxi_p(JIT_R1,JIT_R2, TheRecord(as_object(jit_ptr_field(Record, tfl))));\
574     jit_andi_ul(JIT_R1, JIT_R1,0xFF);\
575     jit_eqi_p(JIT_R0,JIT_R1,Rectype_Svector);\
576 jit_patch(ref);}
577 #define jitc_getlen_svecr()\
578     jitc_get_fieldr(Svector,tfl);\
579     jit_rshi_i(JIT_R0,JIT_R0,8);
580 #define jitc_get_svecdatair(n)\
581     jit_addi_p(JIT_R1, JIT_R2, TheSvector(as_object(jit_ptr_field(Svector, data))));\
582     jit_ldxi_p(JIT_R0, JIT_R1, (n)*sizeof(gcv_object_t));
583 #define jitc_getptr_svecdatair(n)\
584     jit_addi_p(JIT_R1, JIT_R2, TheSvector(as_object(jit_ptr_field(Svector, data))));\
585     jit_addi_p(JIT_R0, JIT_R1, (n)*sizeof(gcv_object_t));
586 /* jitc_get_svecdatax():
587  > JIT_R2: Address of svec
588    JIT_R1: Element position
589  Modifies JIT_R1 */
590 #define jitc_get_svecdatax()\
591     jit_addi_p(JIT_R0, JIT_R2, TheSvector(as_object(jit_ptr_field(Svector, data))));\
592     jit_muli_ul(JIT_R1,JIT_R1,sizeof(gcv_object_t));\
593     jit_ldxr_p(JIT_R0, JIT_R0, JIT_R1);
594 #define jitc_getptr_svecdatax()\
595     jit_addi_p(JIT_R0, JIT_R2, TheSvector(as_object(jit_ptr_field(Svector, data))));\
596     jit_muli_ul(JIT_R1,JIT_R1,sizeof(gcv_object_t));\
597     jit_addr_p(JIT_R0, JIT_R0, JIT_R1);
598 /* ------------------- (6) Calls ----------------------- */
599 #define jitc_funcall()\
600   { jit_prepare(2);\
601         jit_movi_l(JIT_R0,k);\
602         jit_pusharg_p(JIT_R0);\
603         jitc_get_cconsti(n);\
604         jit_pusharg_p(JIT_R0);\
605         jit_finish(funcall);\
606   }
607 #define jitc_funcall0()\
608   { jit_prepare(2);\
609         jit_movi_l(JIT_R0,0);\
610         jit_pusharg_p(JIT_R0);\
611         jitc_get_cconsti(n);\
612         jit_pusharg_p(JIT_R0);\
613         jit_finish(funcall);\
614   }
615 #define jitc_funcall1()\
616   { jit_prepare(2);\
617         jit_movi_l(JIT_R0,1);\
618         jit_pusharg_p(JIT_R0);\
619         jit_ldr_p(JIT_R0,JIT_V1);\
620         jitc_get_cconsti(n);\
621         jit_pusharg_p(JIT_R0);\
622         jit_finish(funcall);\
623   }
624 #define jitc_funcall2()\
625   { jit_prepare(2);\
626         jit_movi_l(JIT_R0,2);\
627         jit_pusharg_p(JIT_R0);\
628         jitc_get_cconsti(n);\
629         jit_pusharg_p(JIT_R0);\
630         jit_finish(funcall);\
631   }
632 /* !!! DO NOT NEST jit_save_backtrace*s */
633 /* jitc_save_backtrace1(fun,stack,num_arg,statement): */
634 /* This one does not dynamically load the 'fun' argument */
635 #define jitc_save_backtrace1(fun,stack,num_arg,statement) {      \
636     jit_addi_p(JIT_R0,JIT_FP,bt_here);                          \
637     jit_ldi_p(JIT_R1,&back_trace);                                      \
638     jit_stxi_i (jit_field(struct backtrace_t, bt_next), JIT_R0, JIT_R1); \
639     jit_movi_l(JIT_R1,(fun));                                           \
640     jit_stxi_i (jit_field(struct backtrace_t, bt_function), JIT_R0, JIT_R1); \
641     jit_ldi_p(JIT_R1,&(stack));                                         \
642     jit_stxi_i (jit_field(struct backtrace_t, bt_stack), JIT_R0, JIT_R1); \
643     jit_movi_l(JIT_R1,(num_arg));                                       \
644     jit_stxi_i (jit_field(struct backtrace_t, bt_num_arg), JIT_R0, JIT_R1); \
645     jit_sti_p(&back_trace, JIT_R0);                                     \
646     statement;                                                          \
647     jit_ldi_p(JIT_R0,&back_trace);                                      \
648     jit_ldxi_p(JIT_R1, JIT_R0, jit_field(struct backtrace_t, bt_next)); \
649     jit_sti_p(&back_trace, JIT_R1);                                     \
650   }
651 /* jitc_save_backtrace2(fun,stack,num_arg,statement):
652  This one dynamically loads the 'fun' argument */
653 #define jitc_save_backtrace2(fun,stack,num_arg,statement) {   \
654     jit_addi_p(JIT_R0,JIT_FP,bt_here);                       \
655     jit_ldi_p(JIT_R1,&back_trace);                                      \
656     jit_stxi_i (jit_field(struct backtrace_t, bt_next), JIT_R0, JIT_R1); \
657     jit_ldi_p(JIT_R1,&(fun));                                           \
658     jit_stxi_i (jit_field(struct backtrace_t, bt_function), JIT_R0, JIT_R1); \
659     jit_ldi_p(JIT_R1,&(stack));                                         \
660     jit_stxi_i (jit_field(struct backtrace_t, bt_stack), JIT_R0, JIT_R1); \
661     jit_movi_l(JIT_R1,(num_arg));                                       \
662     jit_stxi_i (jit_field(struct backtrace_t, bt_num_arg), JIT_R0, JIT_R1); \
663     jit_sti_p(&back_trace, JIT_R0);                                     \
664     statement;                                                          \
665     jit_ldi_p(JIT_R0,&back_trace);                                      \
666     jit_ldxi_p(JIT_R1, JIT_R0, jit_field(struct backtrace_t, bt_next)); \
667     jit_sti_p(&back_trace, JIT_R1);                                     \
668   }
669 /* jitc_save_backtrace3():
670  Saves 'STACK STACKop n' instead of just STACK */
671 #define jitc_save_backtrace3(fun,stack,n,num_arg,statement) {    \
672     jit_addi_p(JIT_R0,JIT_FP,bt_here);                          \
673     jit_ldi_p(JIT_R1,&back_trace);                                      \
674     jit_stxi_i (jit_field(struct backtrace_t, bt_next), JIT_R0, JIT_R1); \
675     jit_movi_l(JIT_R1,(fun));                                           \
676     jit_stxi_i (jit_field(struct backtrace_t, bt_function), JIT_R0, JIT_R1); \
677     jit_ldi_p(JIT_R1,&(stack));                                         \
678     jitc_skip_stack_opir(JIT_R1,JIT_R1,(n)*sizeof(gcv_object_t));        \
679     jit_stxi_i (jit_field(struct backtrace_t, bt_stack), JIT_R0, JIT_R1); \
680     jit_movi_l(JIT_R1,(num_arg));                                       \
681     jit_stxi_i (jit_field(struct backtrace_t, bt_num_arg), JIT_R0, JIT_R1); \
682     jit_sti_p(&back_trace, JIT_R0);                                     \
683     statement;                                                          \
684     jit_ldi_p(JIT_R0,&back_trace);                                      \
685     jit_ldxi_p(JIT_R1, JIT_R0, jit_field(struct backtrace_t, bt_next)); \
686     jit_sti_p(&back_trace, JIT_R1);                                     \
687   }
688 #define jitc_funcalls1();                        \
689   {{ Subr fun = FUNTAB1[n];                                        \
690      jitc_save_backtrace1(as_oint(subr_tab_ptr_as_object(fun)),STACK,-1,\
691                          jit_movi_p(JIT_R0,(fun->function));            \
692                          jit_callr(JIT_R0););                           \
693     }}
694 #define jitc_funcalls2();                        \
695   {{ Subr fun = FUNTAB2[n];                                        \
696      jitc_save_backtrace1(as_oint(subr_tab_ptr_as_object(fun)),STACK,-1,\
697                          jit_movi_p(JIT_R0,(fun->function));      \
698                          jit_callr(JIT_R0););                     \
699     }}
700 #define jitc_funcallsr();                        \
701   {{ Subr fun = FUNTABR[n];                                        \
702      jitc_save_backtrace1(as_oint(subr_tab_ptr_as_object(fun)),STACK,-1,{\
703          jit_prepare(2);                                                \
704          jit_ldi_p(JIT_R1,&(args_end_pointer));                         \
705          jitc_skip_stack_opir(JIT_R0,JIT_R1,m*sizeof(gcv_object_t));    \
706          jit_pusharg_p(JIT_R0);                                         \
707          jit_movi_l(JIT_R0,m);                                          \
708          jit_pusharg_p(JIT_R0);                                         \
709          jit_movi_p(JIT_R0,(fun->function));                            \
710          jit_finishr(JIT_R0);                                           \
711        });}}
712 #define jitc_funcallc()                          \
713   jitc_check_stack();                            \
714   jitc_save_backtrace2(value1, STACK,-1,         \
715                       jit_prepare(3);           \
716                       jitc_get_valuesr_1();                              \
717                       jit_ldxi_p(JIT_R0, JIT_R0, TheCclosure(as_object(jit_ptr_field(Cclosure, clos_codevec)))); \
718                       jit_addi_p(JIT_R0, JIT_R0, TheSbvector(as_object(jit_ptr_field(Sbvector, data)))); \
719                       jit_addi_p(JIT_R0, JIT_R0, CCV_START_NONKEY*sizeof(uint8)); \
720                       jit_pusharg_p(JIT_R0);                            \
721                       jitc_get_valuesr_1();                              \
722                       jit_ldxi_p(JIT_R1, JIT_R0, TheCclosure(as_object(jit_ptr_field(Cclosure, clos_codevec)))); \
723                       jit_addi_p(JIT_R1,JIT_R1,TheSbvector(as_object(0)));         \
724                       jit_pusharg_p(JIT_R1);                            \
725                       jit_pusharg_p(JIT_R0);                            \
726                       jit_finish(cclosure_run););
727 #define jitc_funcallckey()                       \
728   jitc_check_stack();                            \
729   jitc_save_backtrace2(value1, STACK,-1,         \
730                       jit_prepare(3);           \
731                       jitc_get_valuesr_1();                              \
732                       jit_ldxi_p(JIT_R0, JIT_R0, TheCclosure(as_object(jit_ptr_field(Cclosure, clos_codevec)))); \
733                       jit_addi_p(JIT_R0, JIT_R0, TheSbvector(as_object(jit_ptr_field(Sbvector, data)))); \
734                       jit_addi_p(JIT_R0, JIT_R0, CCV_START_KEY*sizeof(uint8)); \
735                       jit_pusharg_p(JIT_R0);                            \
736                       jitc_get_valuesr_1();                              \
737                       jit_ldxi_p(JIT_R1, JIT_R0, TheCclosure(as_object(jit_ptr_field(Cclosure, clos_codevec)))); \
738                       jit_addi_p(JIT_R1,JIT_R1,TheSbvector(as_object(0)));         \
739                       jit_pusharg_p(JIT_R1);                            \
740                       jit_pusharg_p(JIT_R0);                            \
741                       jit_finish(cclosure_run););
742 /* ------------------- (6) Fixnum ----------------------- */
743 #define jitc_val2fixnumr()                       \
744   jit_lshi_ul(JIT_R0,JIT_R2,oint_data_shift);   \
745   jit_movi_l(JIT_R1,fixnum_type);               \
746   jit_lshi_ul(JIT_R1,JIT_R1,oint_type_shift);   \
747   jit_addr_p(JIT_R0,JIT_R0,JIT_R1);
748 #define jitc_posfixnum2valr()\
749   jit_andi_ui(JIT_R0,JIT_R2,((oint)wbitm(oint_data_len+oint_data_shift)-1)); \
750   jit_rshi_ul(JIT_R0,JIT_R0,oint_data_shift);
751 #define jitc_posfixnumpr()                       \
752   jit_movi_l(JIT_R0,7);                         \
753   jit_lshi_ul(JIT_R0,JIT_R0,imm_type_shift);    \
754   jit_ori_ul(JIT_R0,JIT_R0,immediate_bias);     \
755   jit_andr_ul(JIT_R1,JIT_R0,JIT_R2);            \
756   jit_eqi_p(JIT_R0,JIT_R1,fixnum_type);
757 
758 #define jitc_inc_posfixnumir(n)                  \
759   jit_movi_l(JIT_R0,n);                         \
760   jit_lshi_ul(JIT_R0,JIT_R0,oint_data_shift);   \
761   jit_addr_p(JIT_R0,JIT_R0,JIT_R2);
762 
763 /* Might need to reassign this to a function hence the 'x' */
764 #define jitc_ul2ix() jitc_val2fixnumr()
765 
766 #if (oint_data_len>=intVsize)
767     #define jitc_fixnum2valr()  jitc_posfixnum2valr();
768 #elif (sign_bit_o == oint_data_len+oint_data_shift)
769   #define jitc_fixnum2valr()\
770         jit_lshi_ul(JIT_R0,JIT_R2,(intVsize-1-sign_bit_o));\
771         jit_rshi_ul(JIT_R0,JIT_R0,(intVsize-1-sign_bit_o+oint_data_shift));
772 #else
773   #define jitc_fixnum2valr()\
774         jit_rshi_l(JIT_R1,JIT_R2,sign_bit_o);\
775         jit_lshi_l(JIT_R1,JIT_R1,(intVsize-1));\
776         jit_rshi_l(JIT_R1,JIT_R1,(intVsize-1-oint_data_len));\
777         jit_andi_ul(JIT_R0,JIT_R2,((oint)wbitm(oint_data_len+oint_data_shift)-1));\
778         jit_rshi_ul(JIT_R0,JIT_R0,oint_data_shift);\
779         jit_orr_ul(JIT_R0,JIT_R0,JIT_R1);
780 #endif
781 
782 
783 /* ------------------- (X) Debugging ----------------------- */
784 #define jitc_debug()\
785     disassemble(stderr, codeBuffer, jit_get_ip().ptr);
786 /* Prints to STDOUT */
787 /* Carefull, since a C function is called, JIT_R* might get modified */
788 #define jitc_printm(mes)\
789     jit_movi_l(JIT_R0, mes);\
790     jit_prepare(3);\
791     jit_pusharg_p(JIT_R2);\
792     jit_pusharg_p(JIT_R2);\
793     jit_pusharg_p(JIT_R0);\
794     jit_finish(printf);
795 #define jitc_printr()\
796     jit_movi_i(JIT_R0, "The register equals: I=%d, P=%p\n");\
797     jit_prepare(3);\
798     jit_pusharg_p(JIT_R2);\
799     jit_pusharg_p(JIT_R2);\
800     jit_pusharg_p(JIT_R0);\
801     jit_finish(printf);
802 #define jitc_printi(val)\
803     jit_movi_p(JIT_R0, "The variable equals: I=%d, P=%p\n");\
804     jit_movi_l(JIT_R1, val);\
805     jit_prepare(3);\
806     jit_pusharg_p(JIT_R1);\
807     jit_pusharg_p(JIT_R1);\
808     jit_pusharg_p(JIT_R0);\
809     jit_finish(printf);
810 
811 /* ---------------------- JIT BYTECODE COMPILER ---------------------- */
812 
813 /* Compiles the bytecode of a compiled Closure to machine code. See jit.h
814    jit_compile_(closure,codeptr,byteptr);
815    > closure: compiled closure
816    > codeptr: its Codevector, a Simple-Bit-Vector, pointable
817    > byteptr: Start-Bytecodepointer
818    < mv_count/mv_space: values
819    changes STACK, cannot trigger GC */
820 /* Syntax of local labels in GNU-C assembler-statements: */
821 #if (defined(GNU) || defined(INTEL)) && !defined(NO_ASM)
822 /* LD(x) defines Label with number x */
823 /* LR(x,f) references label with number x forwards */
824 /* LR(x,b) references label with number x backwards */
825 /* The scope of the labels is only one assembler-statement. */
826   #if defined(I80386)
827     #ifdef ASM_UNDERSCORE
828       #define LD(nr)  "LASM%=X" STRING(nr)
829       #define LR(nr,fb)  "LASM%=X" STRING(nr)
830     #else
831       #define LD(nr)  ".LASM%=X" STRING(nr)
832       #define LR(nr,fb)  ".LASM%=X" STRING(nr)
833     #endif
834   #elif defined(ARM)
835     #define LD(nr)  "LASM%=X" STRING(nr)
836     #define LR(nr,fb)  "LASM%=X" STRING(nr)
837   #else
838     #define LD(nr)  STRING(nr)
839     #define LR(nr,fb)  STRING(nr) STRING(fb)
840   #endif
841 #endif
842 /* Persuade GNU-C, to keep closure and byteptr in registers: */
843 #if 1
844   #ifdef MC680X0
845     #define closure_register  "a2"
846     #define byteptr_register  "a3"
847   #endif
848   #ifdef SPARC
849     #define closure_register  "%l0"
850     #define byteptr_register  "%l1"
851   #endif
852   #ifdef I80386
853     #if (__GNUC__ >= 2) /* The register-names have changed */
854       #define byteptr_register  "%edi"
855     #else
856       #define byteptr_register  "di"
857     #endif
858   #endif
859   #ifdef ARM
860     /* Code is better without defining registers for closure and byteptr,
861      says Peter Burwood.
862      not define closure_register  "%r6"
863      not define byteptr_register  "%r7"
864      We have assembler macros below, but if they are used with gcc-2.7.2.1,
865      (setf cdddr) is miscompiled. So here we temporarily disable them. */
866     #ifndef NO_ASM
867       #define NO_ASM
868     #endif
869   #endif
870   #ifdef DECALPHA
871     #define byteptr_register  "$14"
872   #endif
873   #if defined(WIDE) && !defined(WIDE_HARD)
874     /* An object does not fit into a single register, GCC is overcharged. */
875     #undef closure_register
876   #endif
877 #endif
878 #ifndef closure_register
879   #define closure_in  closure
880 #endif
881 #ifndef byteptr_register
882   #define byteptr_in  byteptr
883 #endif
884 #ifdef DEBUG_BYTECODE
885   #define GOTO_ERROR(label)  \
886     do {                                              \
887       fprintf(stderr,"\n[%s:%d] ",__FILE__,__LINE__); \
888       goto label;                                     \
889     } while(0)
890 #else
891   #define GOTO_ERROR(label)  goto label
892 #endif
893 /* Operand-Fetch:
894    next Byte:
895      Bit 7 = 0 --> Bits 6..0 are the Operand (7 Bits).
896      Bit 7 = 1 --> Bits 6..0 and next Byte form the
897                    Operand (15 Bits).
898                    For jump-distances: Should this be =0, the next
899                    4 Bytes form the Operand
900                    (32 Bits). */
901 
902 /* Macro B_operand(where);
903  moves the next Operand (a Byte as Unsigned Integer)
904  to (uintL)where and advances  bytecodepointer. */
905 #define B_operand(where)                        \
906   { where = *byteptr++; }
907 
908 /* Macro U_operand(where);
909  moves the next Operand (an Unsigned Integer)
910  to (uintL)where or (uintC)where
911  and advances the Bytecodepointer. */
912 #define U_operand(where)                                     \
913     { where = *byteptr++; /* read first Byte              */ \
914       if ((uintB)where & bit(7)) /* Bit 7 set?            */ \
915         { where &= ~bit(7); /* yes -> delete              */ \
916           where = where << 8;                            \
917           where |= *byteptr++; /* and read next Byte      */ \
918     }   }
919 #if defined(GNU) && defined(MC680X0) && !defined(NO_ASM)
920   #undef U_operand
921   #define U_operand(where)  \
922     __asm__(                 \
923       "moveq #0,%0"   "\n\t" \
924       "moveb %1@+,%0" "\n\t" \
925       "bpl 1f"        "\n\t" \
926       "addb %0,%0"    "\n\t" \
927       "lslw #7,%0"    "\n\t" \
928       "moveb %1@+,%0" "\n"   \
929       "1:"                   \
930       : "=d" (where), "=a" (byteptr) : "1" (byteptr) )
931 #endif
932 #if defined(GNU) && defined(SPARC) && !defined(NO_ASM)
933   #undef U_operand
934   #define U_operand(where)  \
935     { uintL dummy;              \
936       __asm__(                      \
937         "ldub [%1],%0"       "\n\t" \
938         "andcc %0,0x80,%%g0" "\n\t" \
939         "be 1f"              "\n\t" \
940         " add %1,1,%1"       "\n\t" \
941         "sll %0,25,%2"       "\n\t" \
942         "ldub [%1],%0"       "\n\t" \
943         "srl %2,17,%2"       "\n\t" \
944         "add %1,1,%1"        "\n\t" \
945         "or %0,%2,%0"        "\n"   \
946         "1:"                        \
947         : "=r" (where), "=r" (byteptr), "=r" (dummy) : "1" (byteptr) : "ccr" ); \
948     }
949 #endif
950 #if (defined(GNU) || defined(INTEL)) && defined(I80386) && !defined(NO_ASM)
951   #if 0
952     /* In earlier times, the GNU assembler assembled */
953     /* "testb %edx,%edx" as "testb %dl,%dl". This made possible to */
954     /* produce the output in any register. */
955     #define OUT_EAX  "=q"
956     #define EAX      "%0"
957     #define AL       "%0"
958   #else
959     /* Now "testb %edx,%edx" is invalid everywhere. The macros must */
960     /* put their result in %eax. */
961     #define OUT_EAX  "=a"
962     #define EAX      "%%eax"
963     #define AL       "%%al"
964   #endif
965   #undef U_operand
966   #define U_operand(where)  \
967     __asm__(                   \
968       "movzbl (%1),"EAX "\n\t" \
969       "incl %1"         "\n\t" \
970       "testb "AL","AL   "\n\t" \
971       "jge "LR(1,f)     "\n\t" \
972       "andb $127,"AL    "\n\t" \
973       "sall $8,"EAX     "\n\t" \
974       "movb (%1),"AL    "\n\t" \
975       "incl %1"         "\n"   \
976       LD(1)":"                 \
977       : OUT_EAX (where), "=r" (byteptr) : "1" (byteptr) );
978   /* Caution: 1. Der Sun-Assembler doesn't know this Syntax for local labels. */
979   /*              That's why we generate our local labels ourselves. */
980   /* Caution: 2. ccr is changed. How is this to be declared?? */
981 #endif
982 #if defined(GNU) && defined(ARM) && !defined(NO_ASM)
983   /* Macros written by Peter Burwood. */
984   /* Two versions. Which one to choose? */
985   /*        instructions      short case        long case */
986   /* v1:          5           2 + 3 skipped     5 */
987   /* v2:          5           3 + 2 skipped     4 + 1 skipped */
988   /* Let's choose the first one. 1-byte operands are most frequent. */
989   #undef U_operand
990   #define U_operand(where)  /* (v1) */ \
991     { uintL dummy;                     \
992       __asm__(                         \
993         "ldrb   %0,[%1],#1"     "\n\t" \
994         "tst    %0,#0x80"       "\n\t" \
995         "bicne  %0,%0,#0x80"    "\n\t" \
996         "ldrneb %2,[%1],#1"     "\n\t" \
997         "orrne  %0,%2,%0,LSL#8"        \
998         : "=r" (where), "=r" (byteptr), "=r" (dummy) : "1" (byteptr) : "cc" ); \
999     }
1000   #if 0
1001   #undef U_operand
1002   #define U_operand(where)  /* (v2) */ \
1003     { uintL dummy;                     \
1004       __asm__(                         \
1005         "ldrb   %0,[%1],#1"     "\n\t" \
1006         "movs   %0,%0,LSL#25"   "\n\t" \
1007         "movcc  %0,%0,LSR#25"   "\n\t" \
1008         "ldrcsb %2,[%1],#1"     "\n\t" \
1009         "orrcs  %0,%2,%0,LSR#17"       \
1010         : "=r" (where), "=r" (byteptr), "=r" (dummy) : "1" (byteptr) : "cc" ); \
1011     }
1012   #endif
1013 #endif
1014 
1015 /* Macro S_operand(where); */
1016 /* moves the next Operand (a Signed Integer) */
1017 /* to (uintL)where and advances the bytecodepointer. */
1018   #define S_operand(where)  \
1019     { where = *byteptr++; /* read first byte                */ \
1020       if ((uintB)where & bit(7))                           \
1021         /* Bit 7 was set                                    */ \
1022         { where = where << 8;                              \
1023           where |= *byteptr++; /* subjoin next Byte         */ \
1024           /* Sign-Extend from 15 to 32 Bits:                */ \
1025           where = (sintL)((sintL)(sintWL)((sintWL)where << (intWLsize-15)) >> (intWLsize-15)); \
1026           if (where == 0)                                  \
1027             /* special case: 2-Byte-Operand = 0 -> 6-Byte-Operand */ \
1028             { where = (uintL)( ((uintWL)(byteptr[0]) << 8) \
1029                               | (uintWL)(byteptr[1])       \
1030                              ) << 16                       \
1031                     | (uintL)( ((uintWL)(byteptr[2]) << 8) \
1032                               | (uintWL)(byteptr[3])       \
1033                              );                            \
1034               byteptr += 4;                                \
1035         }   }                                              \
1036         else                                               \
1037         /* Bit 7 was deleted                                */ \
1038         { /* Sign-Extend from 7 to 32 Bits:                 */ \
1039           where = (sintL)((sintL)(sintBWL)((sintBWL)where << (intBWLsize-7)) >> (intBWLsize-7)); \
1040         }                                                  \
1041     }
1042 #if defined(GNU) && defined(MC680X0) && !defined(NO_ASM)
1043   #undef S_operand
1044   #define S_operand(where)  \
1045     __asm__(                   \
1046       "moveb %1@+,%0"   "\n\t" \
1047       "bpl 1f"          "\n\t" \
1048       "lslw #8,%0"      "\n\t" \
1049       "moveb %1@+,%0"   "\n\t" \
1050       "addw %0,%0"      "\n\t" \
1051       "asrw #1,%0"      "\n\t" \
1052       "bne 2f"          "\n\t" \
1053       "moveb %1@(2),%0" "\n\t" \
1054       "swap %0"         "\n\t" \
1055       "moveb %1@+,%0"   "\n\t" \
1056       "lsll #8,%0"      "\n\t" \
1057       "moveb %1@,%0"    "\n\t" \
1058       "swap %0"         "\n\t" \
1059       "addql #2,%0"     "\n\t" \
1060       "moveb %1@+,%0"   "\n\t" \
1061       "jra 3f"          "\n"   \
1062       "1:"                "\t" \
1063       "addb %0,%0"      "\n\t" \
1064       "asrb #1,%0"      "\n\t" \
1065       "extw %0"         "\n"   \
1066       "2:"                "\t" \
1067       "extl %0"         "\n"   \
1068       "3:"                     \
1069       : "=d" (where), "=a" (byteptr) : "1" (byteptr) )
1070 #endif
1071 #if defined(GNU) && defined(SPARC) && !defined(NO_ASM)
1072   #undef S_operand
1073   #define S_operand(where)  \
1074     { uintL dummy;                  \
1075       __asm__(                      \
1076         "ldub [%1],%0"       "\n\t" \
1077         "andcc %0,0x80,%%g0" "\n\t" \
1078         "be 2f"              "\n\t" \
1079         " add %1,1,%1"       "\n\t" \
1080         "sll %0,25,%2"       "\n\t" \
1081         "ldub [%1],%0"       "\n\t" \
1082         "sra %2,17,%2"       "\n\t" \
1083         "orcc %2,%0,%0"      "\n\t" \
1084         "bne 3f"             "\n\t" \
1085         " add %1,1,%1"       "\n\t" \
1086         "ldub [%1],%0"       "\n\t" \
1087         "sll %0,24,%2"       "\n\t" \
1088         "ldub [%1+1],%0"     "\n\t" \
1089         "sll %0,16,%0"       "\n\t" \
1090         "or %2,%0,%2"        "\n\t" \
1091         "ldub [%1+2],%0"     "\n\t" \
1092         "sll %0,8,%0"        "\n\t" \
1093         "or %2,%0,%2"        "\n\t" \
1094         "ldub [%1+3],%0"     "\n\t" \
1095         "or %2,%0,%0"        "\n\t" \
1096         "b 3f"               "\n\t" \
1097         " add %1,4,%1"       "\n"   \
1098         "2:"                   "\t" \
1099         "sll %0,25,%0"       "\n\t" \
1100         "sra %0,25,%0"       "\n"   \
1101         "3:"                   "\t" \
1102         : "=r" (where), "=r" (byteptr), "=r" (dummy) : "1" (byteptr) : "ccr" ); \
1103     }
1104 #endif
1105 #if (defined(GNU) || defined(INTEL)) && defined(I80386) && !defined(NO_ASM)
1106   #undef S_operand
1107   #define S_operand(where)  \
1108     __asm__(                   \
1109       "movzbl (%1),"EAX "\n\t" \
1110       "incl %1"         "\n\t" \
1111       "testb "AL","AL   "\n\t" \
1112       "jge "LR(1,f)     "\n\t" \
1113       "sall $8,"EAX     "\n\t" \
1114       "movb (%1),"AL    "\n\t" \
1115       "incl %1"         "\n\t" \
1116       "sall $17,"EAX    "\n\t" \
1117       "sarl $17,"EAX    "\n\t" \
1118       "jne "LR(2,f)     "\n\t" \
1119       "movb (%1),"AL    "\n\t" \
1120       "sall $8,"EAX     "\n\t" \
1121       "movb 1(%1),"AL   "\n\t" \
1122       "sall $8,"EAX     "\n\t" \
1123       "movb 2(%1),"AL   "\n\t" \
1124       "sall $8,"EAX     "\n\t" \
1125       "movb 3(%1),"AL   "\n\t" \
1126       "addl $4,"EAX     "\n\t" \
1127       "jmp "LR(2,f)     "\n"   \
1128       LD(1)":"            "\t" \
1129       "sall $25,"EAX    "\n\t" \
1130       "sarl $25,"EAX    "\n"   \
1131       LD(2)":"                 \
1132       : OUT_EAX (where), "=r" (byteptr) : "1" (byteptr) );
1133 #endif
1134 #if defined(GNU) && defined(ARM) && !defined(NO_ASM)
1135   /* Macro written by Peter Burwood. */
1136   #undef S_operand
1137   #define S_operand(where)  \
1138     { uintL dummy;                      \
1139       __asm__(                          \
1140         "ldrb   %0,[%1],#1"      "\n\t" \
1141         "movs   %0,%0,LSL#25"    "\n\t" \
1142         "movcc  %0,%0,ASR#25"    "\n\t" \
1143         "bcc    "LR(1,f)         "\n\t" \
1144         "ldrb   %2,[%1],#1"      "\n\t" \
1145         "orr    %0,%0,%2,LSL#17" "\n\t" \
1146         "movs   %0,%0,ASR#17"    "\n\t" \
1147         "bne    "LR(1,f)         "\n\t" \
1148         "ldrb   %0,[%1],#1"      "\n\t" \
1149         "ldrb   %2,[%1],#1"      "\n\t" \
1150         "orr    %0,%2,%0,LSL#8"  "\n\t" \
1151         "ldrb   %2,[%1],#1"      "\n\t" \
1152         "orr    %0,%2,%0,LSL#8"  "\n\t" \
1153         "ldrb   %2,[%1],#1"      "\n\t" \
1154         "orr    %0,%2,%0,LSL#8"  "\n"   \
1155         LD(1)":"                        \
1156         : "=r" (where), "=r" (byteptr), "=r" (dummy) : "1" (byteptr) : "cc" ); \
1157     }
1158 #endif
1159 
1160 /* Macro S_operand_ignore(); */
1161 /* skips the next Operand (a Signed Integer) */
1162 /* and advances the bytecodepointer. */
1163   #define S_operand_ignore()  \
1164     { uintB where = *byteptr++; /* read first byte          */ \
1165       if ((uintB)where & bit(7))                               \
1166         /* Bit 7 war gesetzt                                    */ \
1167         { if ((uintB)((where<<1) | *byteptr++) == 0) /* next Byte */ \
1168             /* special case: 2-Byte-Operand = 0 -> 6-Byte-Operand */ \
1169             { byteptr += 4; }                                  \
1170     }   }
1171 #if defined(GNU) && defined(MC680X0) && !defined(NO_ASM)
1172   #undef S_operand_ignore
1173   #define S_operand_ignore()  \
1174     { uintB where;               \
1175       __asm__(                   \
1176         "moveb %1@+,%0"   "\n\t" \
1177         "bpl 1f"          "\n\t" \
1178         "addb %0,%0"      "\n\t" \
1179         "orb %1@+,%0"     "\n\t" \
1180         "bne 1f"          "\n\t" \
1181         "addql #4,%1"     "\n"   \
1182         "1:"                     \
1183         : "=d" (where), "=a" (byteptr) : "1" (byteptr) ); \
1184     }
1185 #endif
1186 #if defined(GNU) && defined(SPARC) && !defined(NO_ASM)
1187   #undef S_operand_ignore
1188   #define S_operand_ignore()  \
1189     { uintL where;                  \
1190       uintL dummy;                  \
1191       __asm__(                      \
1192         "ldub [%1],%0"       "\n\t" \
1193         "andcc %0,0x80,%%g0" "\n\t" \
1194         "be 1f"              "\n\t" \
1195         " add %1,1,%1"       "\n\t" \
1196         "sll %0,1,%2"        "\n\t" \
1197         "ldub [%1],%0"       "\n\t" \
1198         "orcc %2,%0,%0"      "\n\t" \
1199         "bne 1f"             "\n\t" \
1200         " add %1,1,%1"       "\n\t" \
1201         "add %1,4,%1"        "\n"   \
1202         "1:"                        \
1203         : "=r" (where), "=r" (byteptr), "=r" (dummy) : "1" (byteptr) : "ccr" ); \
1204     }
1205 #endif
1206 #if defined(GNU) && defined(ARM) && !defined(NO_ASM)
1207   /* Macro written by Peter Burwood. */
1208   #undef S_operand_ignore
1209   #define S_operand_ignore()  \
1210     { uintL where;                  \
1211       uintL dummy;                  \
1212       __asm__(                          \
1213         "ldrb   %0,[%1],#1"      "\n\t" \
1214         "movs   %0,%0,LSL#25"    "\n\t" \
1215         "bcc    "LR(1,f)         "\n\t" \
1216         "ldrb   %2,[%1],#1"      "\n\t" \
1217         "orrs   %0,%2,%0,LSR#24" "\n\t" \
1218         "addeq  %1,%1,#4"        "\n"   \
1219         LD(1)":"                        \
1220         : "=r" (where), "=r" (byteptr), "=r" (dummy) : "1" (byteptr) : "cc" ); \
1221     }
1222 #endif
1223 
1224 /* Macro L_operand(where); */
1225 /* moves the next Operand (a Label) */
1226 /* to (uintB*)where and advances the bytecodepointer. */
1227   #define L_operand(Lwhere)  \
1228     { uintL where; /* variable for the displacement */ \
1229       S_operand(where); /* Displacement                 */ \
1230       Lwhere = byteptr + (sintL)where; /* add           */ \
1231     }
1232 
1233 /* Macro L_operand_ignore(); */
1234 /* skips the next Operand (a Label) */
1235 /* and advances the Bytecodepointer. */
1236   #define L_operand_ignore()  S_operand_ignore()
1237       #undef CODEPTR
1238       #define CODEPTR  (&codeptr->data[0])
1239 
1240 /* do not use cod_labels */
1241 #ifdef FAST_DISPATCH
1242 #undef next_byte
1243 #endif
1244 
jit_compile_(object closure_in,Sbvector codeptr,const uintB * byteptr_in)1245 static /*maygc*/ Values jit_compile_ (object closure_in, Sbvector codeptr,
1246                                       const uintB* byteptr_in)
1247 {
1248   GCTRIGGER_IF(true, {
1249       if (*byteptr_in == cod_handler_begin_push)
1250         GCTRIGGER3(closure_in,handler_args.condition,handler_args.spdepth);
1251       else
1252         GCTRIGGER1(closure_in);
1253     });
1254   /* situate argument closure in register: */
1255   #ifdef closure_register
1256   object closure __asm__(closure_register);
1257   closure = closure_in;
1258   #endif
1259   /* situate argument byteptr in register: */
1260   #ifdef byteptr_register
1261   register const uintB* byteptr __asm__(byteptr_register);
1262   byteptr = byteptr_in;
1263   #endif
1264   TRACE_CALL(closure,'B','C');
1265 
1266   const uintB* saved_byteptr = byteptr;
1267   /* byteptr_min is never zero: Codevec is stored in the first bytes of the Sbvector */
1268   const uintL byteptr_min = ((Codevec)codeptr)->ccv_flags & bit(7)
1269       ? CCV_START_KEY : CCV_START_NONKEY;
1270   const uintL byteptr_max = sbvector_length(codeptr)-1;
1271   const uintL sp_length = (uintL)(((Codevec)codeptr)->ccv_spdepth_1)
1272       + jmpbufsize * (uintL)(((Codevec)codeptr)->ccv_spdepth_jmpbufsize);
1273  #ifdef DEBUG_BYTECODE
1274   sintL byteptr_bad_jump;
1275  #endif
1276 
1277   /* codebuffer: contains the JITed code (Temp allocation scheme) */
1278   jit_insn *codeBuffer = malloc(sizeof(jit_insn)*byteptr_max*JITC_AVG_BCSIZE);
1279   /* bcIndex: Address of the beginning of each BC in codeBuffer
1280      Used by the compiler to patch jumps.  */
1281   jit_insn **bcIndex = calloc(byteptr_max+1,sizeof(jit_insn*));
1282   /* save JITC code into the closure */
1283   struct jitc_object *jo = malloc(sizeof(struct jitc_object));
1284   jo->jo_gc_mark = 0;
1285   jo->code_buffer = codeBuffer;
1286   jo->bc_index = bcIndex;
1287   jo->jo_next = all_jitc_objects;
1288   all_jitc_objects = jo;
1289   TheFpointer(cclosure_jitc(closure))->fp_pointer = jo;
1290 
1291   (void)jit_set_ip(codeBuffer);
1292   jit_prolog(2);
1293   /* Arguments */
1294   const int jitc_arg_closure = jit_arg_i();
1295   const int jitc_arg_startpos= jit_arg_i();
1296   /* Stack allocated variables */
1297   const int jitc_sp_space = (sp_length)?jit_allocai(sizeof(SPint)*sp_length):0;
1298   const int jitc_sp_ptr = jit_allocai(sizeof(void*)); /* top of SP */
1299   const int jitc_var_a = jit_allocai(sizeof(void*)); /* Temp variables */
1300   const int jitc_var_b = jit_allocai(sizeof(void*));
1301   const int jitc_var_c = jit_allocai(sizeof(void*));
1302   const int jitc_var_d = jit_allocai(sizeof(void*));
1303   const int bt_here = jit_allocai(sizeof(struct backtrace_t));
1304   /* Init of jitc_sp_ptr */
1305   jit_addi_p(JIT_R0,JIT_FP,jitc_sp_space);
1306   jit_addi_p(JIT_R0,JIT_R0,sizeof(SPint)*(sp_length)); /* SP grows down */
1307   jit_stxi_p(jitc_sp_ptr,JIT_FP,JIT_R0);
1308 
1309   /* situate closure in STACK, below the arguments: */
1310   jit_getarg_p(JIT_R2, jitc_arg_closure);
1311   jitc_push_stackr();
1312   jitc_getptr_stacki(0);
1313   jit_movr_p(JIT_V1,JIT_R0); /* Permanently in JIT_V1 */
1314 
1315   /* Jump to starting instruction */
1316   jit_getarg_p(JIT_R2, jitc_arg_startpos);
1317   jitc_bcjmpr();
1318 
1319 
1320   /* next Byte to be interpreted */
1321   /* > codeptr: Closure's codevector, a Simple-Bit-Vector, pointable */
1322   /* > byteptr: pointer to the next byte in code */
1323   byteptr = CODEPTR + byteptr_min;
1324 
1325   next_byte:
1326   /* definition by cases, according to byte to be interpreted byte */
1327   if((byteptr - CODEPTR) > byteptr_max)
1328         goto finished;
1329   uintL bcPos = byteptr - CODEPTR;
1330 
1331   jitc_check_overflow();
1332   jitc_patch_fwdjmps();
1333   bcIndex[bcPos] = (jit_insn*)jit_get_ip().ptr;
1334 
1335   switch (*byteptr++)
1336   #define CASE  case (uintB)
1337   { /* ------------------- (1) Constants ----------------------- */
1338     CASE cod_nil: {             /* (NIL) */
1339       jitc_set_valuesi_1(as_oint(NIL));
1340       goto next_byte;
1341     }
1342     CASE cod_nil_push: {        /* (NIL&PUSH) */
1343       jitc_push_stacki(as_oint(NIL));
1344       goto next_byte;
1345     }
1346     CASE cod_push_nil: {        /* (PUSH-NIL n) */
1347       uintC n;
1348       U_operand(n);
1349       if (n != 0 ) {
1350         jit_movi_ui(JIT_R2,n);
1351         jitc_repeatp(JIT_R2,
1352                     jitc_push_stacki(as_oint(NIL));
1353                     );
1354       }
1355       goto next_byte;
1356     }
1357     CASE cod_t: {               /* (T) */
1358       jitc_set_valuesi_1(as_oint(T));
1359       goto next_byte;
1360     }
1361     CASE cod_t_push: {          /* (T&PUSH) */
1362       jitc_push_stacki(as_oint(T));
1363       goto next_byte;
1364     }
1365     CASE cod_const: {           /* (CONST n) */
1366       uintL n;
1367       U_operand(n);
1368 
1369       jitc_get_cconsti(n);
1370       jit_movr_p(JIT_R2,JIT_R0);
1371       jitc_set_valuesr_1();
1372 
1373       goto next_byte;
1374     }
1375     CASE cod_const_push: {      /* (CONST&PUSH n) */
1376       uintL n;
1377       U_operand(n);
1378 
1379       jitc_get_cconsti(n);
1380       jit_movr_p(JIT_R2,JIT_R0);
1381       jitc_push_stackr();
1382 
1383       goto next_byte;
1384     }
1385     /* ------------------- (2) static Variables ----------------------- */
1386     CASE cod_load: {            /* (LOAD n) */
1387       uintL n;
1388       U_operand(n);
1389 
1390       jitc_get_stacki(n);
1391       jit_movr_p(JIT_R2,JIT_R0);
1392       jitc_set_valuesr_1();
1393 
1394       goto next_byte;
1395     }
1396     CASE cod_load_push: {       /* (LOAD&PUSH n) */
1397       uintL n;
1398       U_operand(n);
1399 
1400       jitc_get_stacki(n);
1401       jit_movr_p(JIT_R2,JIT_R0);
1402       jitc_push_stackr();
1403 
1404       goto next_byte;
1405     }
1406     CASE cod_loadi: {           /* (LOADI k1 k2 n) */
1407       uintL k1;
1408       uintL k2;
1409       uintL n;
1410       U_operand(k1);
1411       U_operand(k2);
1412       U_operand(n);
1413 
1414       jitc_get_spi(k1+jmpbufsize*k2);
1415       jit_movr_p(JIT_R2,JIT_R0);
1416       jitc_get_framei(n);
1417       jit_movr_p(JIT_R2,JIT_R0);
1418       jitc_set_valuesr_1();
1419 
1420       goto next_byte;
1421     }
1422     CASE cod_loadi_push: {      /* (LOADI&PUSH k1 k2 n) */
1423       uintL k1;
1424       uintL k2;
1425       uintL n;
1426       U_operand(k1);
1427       U_operand(k2);
1428       U_operand(n);
1429 
1430       jitc_get_spi(k1+jmpbufsize*k2);
1431       jit_movr_p(JIT_R2,JIT_R0);
1432       jitc_get_framei(n);
1433       jit_movr_p(JIT_R2,JIT_R0);
1434       jitc_push_stackr();
1435 
1436       goto next_byte;
1437     }
1438     CASE cod_loadc: {           /* (LOADC n m) */
1439       uintL n;
1440       uintL m;
1441       U_operand(n);
1442       U_operand(m);
1443 
1444       jitc_get_stacki(n);
1445       jit_movr_p(JIT_R2,JIT_R0);
1446       jitc_get_svecdatair(1+m);
1447       jit_movr_p(JIT_R2,JIT_R0);
1448       jitc_set_valuesr_1();
1449 
1450       goto next_byte;
1451     }
1452     CASE cod_loadc_push: {      /* (LOADC&PUSH n m) */
1453       uintL n;
1454       uintL m;
1455       U_operand(n);
1456       U_operand(m);
1457 
1458       jitc_get_stacki(n);
1459       jit_movr_p(JIT_R2,JIT_R0);
1460       jitc_get_svecdatair(1+m);
1461       jit_movr_p(JIT_R2,JIT_R0);
1462       jitc_push_stackr();
1463 
1464       goto next_byte;
1465     }
1466     CASE cod_loadv: {           /* (LOADV k m) */
1467       uintC k;
1468       uintL m;
1469       U_operand(k);
1470       U_operand(m);
1471 
1472       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
1473 
1474       jitc_get_cconsti(0);
1475       jit_movr_p(JIT_R2,JIT_R0);
1476 
1477       if (k != 0) {
1478         jit_movi_l(JIT_V2,k);
1479         jitc_repeatp(JIT_V2,
1480                     jitc_get_fieldr(Svector,data);
1481                     jit_movr_p(JIT_R2,JIT_R0);
1482                     );
1483       }
1484 
1485       jitc_get_svecdatair(m);
1486       jit_movr_p(JIT_R2,JIT_R0);
1487       jitc_set_valuesr_1();
1488 
1489       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
1490 
1491       goto next_byte;
1492     }
1493     CASE cod_loadv_push: {      /* (LOADV&PUSH k m) */
1494       uintC k;
1495       uintL m;
1496       jit_insn* ref;
1497       U_operand(k);
1498       U_operand(m);
1499 
1500       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
1501 
1502       jitc_get_cconsti(0);
1503       jit_movr_p(JIT_R2,JIT_R0);
1504 
1505       if (k != 0) {
1506         jit_movi_l(JIT_V2,k);
1507         jitc_repeatp(JIT_V2,
1508                     jitc_get_fieldr(Svector,data);
1509                     jit_movr_p(JIT_R2,JIT_R0);
1510                     );
1511       }
1512 
1513       jitc_get_svecdatair(m);
1514       jit_movr_p(JIT_R2,JIT_R0);
1515       jitc_push_stackr();
1516 
1517       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
1518 
1519       goto next_byte;
1520     }
1521     CASE cod_loadic: {          /* (LOADIC k1 k2 n m) */
1522       uintL k1;
1523       uintL k2;
1524       uintL n;
1525       uintL m;
1526       U_operand(k1);
1527       U_operand(k2);
1528       U_operand(n);
1529       U_operand(m);
1530 
1531       jitc_get_spi(k1+jmpbufsize*k2);
1532       jit_movr_p(JIT_R2,JIT_R0);
1533       jitc_get_framei(n);
1534       jit_movr_p(JIT_R2,JIT_R0);
1535       jitc_get_svecdatair(1+m);
1536       jit_movr_p(JIT_R2,JIT_R0);
1537       jitc_set_valuesr_1();
1538 
1539       goto next_byte;
1540     }
1541     CASE cod_store: store: {    /* (STORE n) */
1542       uintL n;
1543       U_operand(n);
1544 
1545       jitc_get_valuesr_1();
1546       jit_movr_p(JIT_R2,JIT_R0);
1547       jitc_getptr_stacki(n);
1548       jit_str_p(JIT_R0, JIT_R2);
1549       jitc_set_valuesr_1();
1550 
1551       goto next_byte;
1552     }
1553     CASE cod_pop_store: {       /* (POP&STORE n) */
1554       uintL n;
1555       U_operand(n);
1556 
1557       jitc_pop_stack();
1558       jit_movr_p(JIT_R2,JIT_R0);
1559       jitc_getptr_stacki(n);
1560       jit_str_p(JIT_R0, JIT_R2);
1561       jitc_set_valuesr_1();
1562 
1563       goto next_byte;
1564     }
1565     CASE cod_storei: {          /* (STOREI k1 k2 n) */
1566       uintL k1;
1567       uintL k2;
1568       uintL n;
1569       U_operand(k1);
1570       U_operand(k2);
1571       U_operand(n);
1572 
1573       jitc_get_spi(k1+jmpbufsize*k2);
1574       jit_movr_p(JIT_R2,JIT_R0);
1575       jitc_getptr_framei(n);
1576       jit_str_p(JIT_R0,JIT_R2);
1577       jitc_set_valuesr_1();
1578 
1579       goto next_byte;
1580     }
1581     CASE cod_load_storec: {     /* (LOAD&STOREC k m n) */
1582       uintL k;
1583       uintL n;
1584       uintL m;
1585       U_operand(k);
1586       U_operand(n);
1587       U_operand(m);
1588 
1589       jitc_get_stacki(k);
1590       jit_movr_p(JIT_R2,JIT_R0);
1591       jitc_getptr_valuesr_1();
1592       jit_str_p(JIT_R0,JIT_R2);
1593 
1594       jitc_get_stacki(n);
1595       jit_movr_p(JIT_R2,JIT_R0);
1596       jitc_getptr_svecdatair(1+m);
1597       jit_movr_p(JIT_R2,JIT_R0);
1598       jitc_get_valuesr_1();
1599       jit_str_p(JIT_R2,JIT_R0);
1600       jitc_set_mvcounti(1);
1601 
1602       goto next_byte;
1603     }
1604     CASE cod_storec: {          /* (STOREC n m) */
1605       uintL n;
1606       uintL m;
1607       U_operand(n);
1608       U_operand(m);
1609 
1610       jitc_get_stacki(n);
1611       jit_movr_p(JIT_R2,JIT_R0);
1612       jitc_getptr_svecdatair(1+m);
1613       jit_movr_p(JIT_R2,JIT_R0);
1614       jitc_get_valuesr_1();
1615       jit_str_p(JIT_R2,JIT_R0);
1616       jitc_set_mvcounti(1);
1617 
1618       goto next_byte;
1619     }
1620     CASE cod_storev: {                /* (STOREV k m) */
1621       uintC k;
1622       uintL m;
1623       U_operand(k);
1624       U_operand(m);
1625 
1626       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
1627 
1628       jitc_get_cconsti(0);
1629       jit_movr_p(JIT_R2,JIT_R0);
1630 
1631       if (k != 0) {
1632         jit_movi_l(JIT_V2,k);
1633         jitc_repeatp(JIT_V2,
1634                     jitc_get_fieldr(Svector,data);
1635                     jit_movr_p(JIT_R2,JIT_R0);
1636                     );
1637       }
1638 
1639       jitc_getptr_svecdatair(m);
1640       jit_movr_p(JIT_R2,JIT_R0);
1641       jitc_get_valuesr_1();
1642       jit_str_p(JIT_R2,JIT_R0);
1643       jitc_set_mvcounti(1);
1644 
1645       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
1646 
1647       goto next_byte;
1648     }
1649     CASE cod_storeic: {         /* (STOREIC k1 k2 n m) */
1650       uintL k1;
1651       uintL k2;
1652       uintL n;
1653       uintL m;
1654       U_operand(k1);
1655       U_operand(k2);
1656       U_operand(n);
1657       U_operand(m);
1658 
1659       jitc_get_spi(k1+jmpbufsize*k2);
1660       jit_movr_p(JIT_R2,JIT_R0);
1661       jitc_get_framei(n);
1662       jit_movr_p(JIT_R2,JIT_R0);
1663       jitc_get_svecdatair(1+m);
1664       jit_movr_p(JIT_R2,JIT_R0);
1665       jitc_get_valuesr_1();
1666       jit_str_p(JIT_R2,JIT_R0);
1667       jitc_set_mvcounti(1);
1668 
1669       goto next_byte;
1670     }
1671     /* ------------------- (3) dynamic Variables ----------------------- */
1672     CASE cod_getvalue: {        /* (GETVALUE n) */
1673       uintL n;
1674       jit_insn  *ref;
1675       U_operand(n);
1676 
1677       jitc_get_cconsti(n);
1678       jit_movr_p(JIT_R2,JIT_R0);
1679       jitc_get_symvalr();
1680       ref = jit_bnei_p(jit_forward(), JIT_R0, as_oint(unbound));
1681       jitc_push_stackr();
1682       jitc_push_stackr();
1683       jitc_errori(unbound_variable,"~S: symbol ~S has no value");
1684       jit_patch(ref);
1685       jit_movr_p(JIT_R2,JIT_R0);
1686       jitc_set_valuesr_1();
1687 
1688       goto next_byte;
1689     }
1690     CASE cod_getvalue_push: {         /* (GETVALUE&PUSH n) */
1691       uintL n;
1692       jit_insn  *ref;
1693       U_operand(n);
1694 
1695       jitc_get_cconsti(n);
1696       jit_movr_p(JIT_R2,JIT_R0);
1697       jitc_get_symvalr();
1698       ref = jit_bnei_p(jit_forward(), JIT_R0, as_oint(unbound));
1699       jitc_push_stackr();
1700       jitc_push_stackr();
1701       jitc_errori(unbound_variable,"~S: symbol ~S has no value");
1702       jit_patch(ref);
1703       jit_movr_p(JIT_R2,JIT_R0);
1704       jitc_push_stackr();
1705 
1706       goto next_byte;
1707     }
1708     CASE cod_setvalue: {        /* (SETVALUE n) */
1709       uintL n;
1710       jit_insn  *ref;
1711       U_operand(n);
1712 
1713       jitc_get_cconsti(n);
1714       jit_movr_p(JIT_R2,JIT_R0);
1715       jitc_sym_constpr();
1716       ref = jit_bnei_p(jit_forward(), JIT_R0, 1);
1717       jitc_push_stackr();
1718       jitc_getptr_fieldr(Cclosure, clos_consts);
1719       jit_ldxi_p(JIT_R2,JIT_R0,sizeof(gcv_object_t));
1720       jitc_push_stackr();
1721       jitc_errori(error_condition,"~S: assignment to constant symbol ~S is impossible");
1722       jit_patch(ref);
1723       jitc_getptr_symvalr();
1724       jit_movr_p(JIT_R2,JIT_R0);
1725       jitc_get_valuesr_1();
1726       jit_str_p(JIT_R2,JIT_R0);
1727       jitc_set_mvcounti(1);
1728 
1729       goto next_byte;
1730     }
1731     CASE cod_bind: {            /* (BIND n) */
1732       uintL n;
1733       U_operand(n);
1734 
1735       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
1736 
1737       jitc_get_cconsti(n);
1738       jit_movr_p(JIT_V2,JIT_R0);
1739       jit_movr_p(JIT_R2,JIT_V2);
1740       /* Create frame : */
1741       jitc_get_symvalr();
1742       jit_movr_p(JIT_R2,JIT_R0);
1743       jitc_push_stackr();
1744       jit_movr_p(JIT_R2,JIT_V2);
1745       jitc_push_stackr();
1746       jitc_finish_framer(DYNBIND,3);
1747       /* modify value */
1748       jitc_getptr_symvalr();
1749       jit_ldi_p(JIT_R1, &(value1));
1750       jit_str_p(JIT_R0, JIT_R1);
1751 
1752       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
1753 
1754       goto next_byte;
1755     }
1756     CASE cod_unbind1: {               /* (UNBIND1) */
1757       /* unwind variable-binding-frame: */
1758       jit_insn *rf1,*rf2;
1759 
1760       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
1761       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
1762 
1763       jitc_getptr_stacki(0);
1764       jit_movr_p(JIT_R2,JIT_R0);
1765       jitc_gettop_framer();
1766       jit_movr_p(JIT_R2,JIT_R0);
1767       jit_stxi_p(jitc_var_c,JIT_FP,JIT_R2); /* new_stack */
1768       jitc_getptbl_stackr();
1769       jit_movr_p(JIT_V2,JIT_R0); /* frame_end */
1770       jitc_getptr_stacki(1);
1771       jit_movr_p(JIT_V1,JIT_R0); /* bindingptr */
1772 
1773       rf1 = jit_get_label();
1774       rf2 = jit_beqr_p(jit_forward(),JIT_V1,JIT_V2);
1775       jit_ldr_p(JIT_R2,JIT_V1);
1776       jitc_getptr_symvalr();
1777       jit_movr_p(JIT_R2,JIT_R0);
1778       jitc_skip_stack_opir(JIT_R1,JIT_V1,sizeof(gcv_object_t));
1779       jit_ldr_p(JIT_R0,JIT_R1);
1780       jit_str_p(JIT_R2,JIT_R0);
1781 
1782       jitc_skip_stack_opir(JIT_V1,JIT_V1,2*sizeof(gcv_object_t));
1783       (void)jit_jmpi(rf1);
1784       jit_patch(rf2);
1785 
1786       jit_ldxi_p(JIT_R0,JIT_FP,jitc_var_c); /* new_stack */
1787       jit_sti_p(&STACK,JIT_R0);
1788 
1789       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
1790       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
1791 
1792       goto next_byte;
1793     }
1794     CASE cod_unbind: {          /* (UNBIND n) */
1795       uintC n;
1796       jit_insn *rf1,*rf2,*rf3;
1797       U_operand(n); /* n>0 */
1798 
1799       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
1800       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
1801 
1802       jit_ldi_p(JIT_V2,&STACK); /* FRAME */
1803       jit_movi_l(JIT_R0,n);
1804       jit_stxi_p(jitc_var_c,JIT_FP,JIT_R0);
1805       rf1 = jit_get_label();
1806       jit_movr_p(JIT_R2,JIT_V2);
1807       jitc_getptr_framei(1);
1808       jit_movr_p(JIT_V1,JIT_R0); /* bindingptr */
1809       jitc_getptr_framei(0);
1810       jit_movr_p(JIT_R2,JIT_R0);
1811       jitc_gettop_framer();
1812       jit_movr_p(JIT_R2,JIT_R0);
1813       jit_stxi_p(jitc_var_d,JIT_FP,JIT_R2); /* new_frame */
1814       jitc_getptbl_stackr();
1815       jit_movr_p(JIT_V2,JIT_R0); /* frame_end */
1816 
1817       rf2 = jit_get_label();
1818       rf3 = jit_beqr_p(jit_forward(),JIT_V1,JIT_V2);
1819       jit_ldr_p(JIT_R2,JIT_V1);
1820       jitc_getptr_symvalr();
1821       jit_movr_p(JIT_R2,JIT_R0);
1822       jitc_skip_stack_opir(JIT_R1,JIT_V1,sizeof(gcv_object_t));
1823       jit_ldr_p(JIT_R0,JIT_R1);
1824       jit_str_p(JIT_R2,JIT_R0);
1825 
1826       jitc_skip_stack_opir(JIT_V1,JIT_V1,2*sizeof(gcv_object_t));
1827       (void)jit_jmpi(rf2);
1828       jit_patch(rf3);
1829 
1830       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_d); /* new_frame */
1831 
1832       jit_ldxi_p(JIT_R0,JIT_FP,jitc_var_c);
1833       jit_subi_i(JIT_R2,JIT_R0,1);
1834       jit_stxi_p(jitc_var_c,JIT_FP,JIT_R2);
1835       jit_bnei_i(rf1,JIT_R2,0);
1836 
1837       jit_sti_p(&STACK,JIT_V2);
1838 
1839       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
1840       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
1841 
1842       goto next_byte;
1843     }
1844     CASE cod_progv: {           /* (PROGV) */
1845       jit_ldi_p(JIT_R0,&STACK);
1846       jitc_skip_stack_opir(JIT_R2,JIT_R0,sizeof(gcv_object_t));
1847       jitc_push_spr();
1848       jit_prepare(2);
1849       jitc_get_valuesr_1();
1850       jit_pusharg_p(JIT_R0);
1851       jitc_pop_stack();
1852       jit_pusharg_p(JIT_R0);
1853       jit_finish(progv);
1854 
1855       jitc_tag_unsafe();
1856       goto next_byte;
1857     }
1858     /* ------------------- (4) Stack operations ----------------------- */
1859     CASE cod_push: {            /* (PUSH) */
1860       jitc_get_valuesr_1();
1861       jit_movr_p(JIT_R2,JIT_R0);
1862       jitc_push_stackr();
1863 
1864       goto next_byte;
1865     }
1866     CASE cod_pop: {             /* (POP) */
1867       jitc_pop_stack();
1868       jit_movr_p(JIT_R2,JIT_R0);
1869       jitc_set_valuesr_1();
1870 
1871       goto next_byte;
1872     }
1873     CASE cod_skip: {            /* (SKIP n) */
1874       uintL n;
1875       U_operand(n);
1876 
1877       jitc_skip_stacki(n);
1878 
1879       goto next_byte;
1880     }
1881     CASE cod_skipi: {           /* (SKIPI k1 k2 n) */
1882       uintL k1;
1883       uintL k2;
1884       uintL n;
1885       U_operand(k1);
1886       U_operand(k2);
1887       U_operand(n);
1888 
1889       jitc_skip_spi(k1+jmpbufsize*k2);
1890       jitc_pop_sp();
1891       jitc_skip_stack_opir(JIT_R1,JIT_R0,n*sizeof(gcv_object_t));
1892       jit_sti_p(&STACK,JIT_R1);
1893 
1894       goto next_byte;
1895     }
1896     CASE cod_skipsp: {          /* (SKIPSP k1 k2) */
1897       uintL k1;
1898       uintL k2;
1899       U_operand(k1);
1900       U_operand(k2);
1901 
1902       jitc_skip_spi(k1+jmpbufsize*k2);
1903 
1904       goto next_byte;
1905     }
1906     /* ------------------- (5) Control Flow and Jumps ----------------------- */
1907     CASE cod_skip_ret: {        /* (SKIP&RET n) */
1908       uintL n;
1909       U_operand(n);
1910 
1911       jitc_skip_stacki(n);
1912 
1913       jitc_return();
1914 
1915       goto next_byte;
1916     }
1917     CASE cod_skip_retgf: {      /* (SKIP&RETGF n) */
1918       uintL n;
1919       U_operand(n);
1920       if (((Codevec)codeptr)->ccv_flags & bit(3)) { /* call inhibition? */
1921         jitc_skip_stacki(n);
1922         jitc_set_mvcounti(1);
1923       } else {
1924         uintL r = ((Codevec)codeptr)->ccv_numreq;
1925         n -= r;
1926         if (((Codevec)codeptr)->ccv_flags & bit(0)) {
1927           jitc_skip_stacki(n-1);
1928           jit_prepare(3);
1929           jitc_pop_stack();
1930           jit_pusharg_p(JIT_R0);
1931           jit_movi_l(JIT_R0,r);
1932           jit_pusharg_p(JIT_R0);
1933           jitc_get_valuesr_1();
1934           jit_pusharg_p(JIT_R0);
1935           jit_finish(apply);
1936         } else {
1937           jitc_skip_stacki(n);
1938           jit_prepare(2);
1939           jit_movi_l(JIT_R0,r);
1940           jit_pusharg_p(JIT_R0);
1941           jitc_get_valuesr_1();
1942           jit_pusharg_p(JIT_R0);
1943           jit_finish(funcall);
1944         }
1945       }
1946       jitc_return();
1947 
1948       goto next_byte;
1949     }
1950     CASE cod_jmp: {             /* (JMP label) */
1951       const uintB* label_byteptr;
1952       L_operand(label_byteptr);
1953 
1954       jitc_bcjmpi(label_byteptr - CODEPTR);
1955 
1956       goto next_byte;
1957     }
1958     CASE cod_jmpif: {           /* (JMPIF label) */
1959       jit_insn *rf1;
1960       const uintB* label_byteptr;
1961       L_operand(label_byteptr);
1962 
1963       jitc_get_valuesr_1();
1964       rf1 = jit_beqi_p(jit_forward(),JIT_R0,as_oint(NIL));
1965       jitc_bcjmpi(label_byteptr - CODEPTR);
1966       jit_patch(rf1);
1967 
1968       goto next_byte;
1969     }
1970     CASE cod_jmpifnot: {        /* (JMPIFNOT label) */
1971       jit_insn *rf1;
1972       const uintB* label_byteptr;
1973       L_operand(label_byteptr);
1974 
1975       jitc_get_valuesr_1();
1976       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(NIL));
1977       jitc_bcjmpi(label_byteptr - CODEPTR);
1978       jit_patch(rf1);
1979 
1980       goto next_byte;
1981     }
1982     CASE cod_jmpif1: {          /* (JMPIF1 label) */
1983       jit_insn *rf1;
1984       const uintB* label_byteptr;
1985       L_operand(label_byteptr);
1986 
1987       jitc_get_valuesr_1();
1988       rf1 = jit_beqi_p(jit_forward(),JIT_R0,as_oint(NIL));
1989       jitc_set_mvcounti(1);
1990       jitc_bcjmpi(label_byteptr - CODEPTR);
1991       jit_patch(rf1);
1992 
1993       goto next_byte;
1994     }
1995     CASE cod_jmpifnot1: {       /* (JMPIFNOT1 label) */
1996       jit_insn *rf1;
1997       const uintB* label_byteptr;
1998       L_operand(label_byteptr);
1999 
2000       jitc_get_valuesr_1();
2001       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(NIL));
2002       jitc_set_mvcounti(1);
2003       jitc_bcjmpi(label_byteptr - CODEPTR);
2004       jit_patch(rf1);
2005 
2006       goto next_byte;
2007     }
2008     CASE cod_jmpifatom: {       /* (JMPIFATOM label) */
2009       jit_insn *rf1;
2010       const uintB* label_byteptr;
2011       L_operand(label_byteptr);
2012 
2013       jitc_get_valuesr_1();
2014       jit_movr_p(JIT_R2,JIT_R0);
2015       jitc_sym_atompr();
2016       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
2017       jitc_bcjmpi(label_byteptr - CODEPTR);
2018       jit_patch(rf1);
2019 
2020       goto next_byte;
2021     }
2022     CASE cod_jmpifconsp: {      /* (JMPIFCONSP label) */
2023       jit_insn *rf1;
2024       const uintB* label_byteptr;
2025       L_operand(label_byteptr);
2026 
2027       jitc_get_valuesr_1();
2028       jit_movr_p(JIT_R2,JIT_R0);
2029       jitc_sym_conspr();
2030       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
2031       jitc_bcjmpi(label_byteptr - CODEPTR);
2032       jit_patch(rf1);
2033 
2034       goto next_byte;
2035     }
2036     CASE cod_jmpifeq: {         /* (JMPIFEQ label) */
2037       jit_insn *rf1;
2038       const uintB* label_byteptr;
2039       L_operand(label_byteptr);
2040 
2041       jitc_get_valuesr_1();
2042       jit_movr_p(JIT_R2,JIT_R0);
2043       jitc_pop_stack();
2044       rf1 = jit_bner_p(jit_forward(),JIT_R0,JIT_R2);
2045       jitc_bcjmpi(label_byteptr - CODEPTR);
2046       jit_patch(rf1);
2047 
2048       goto next_byte;
2049     }
2050     CASE cod_jmpifnoteq: {      /* (JMPIFNOTEQ label) */
2051       jit_insn *rf1;
2052       const uintB* label_byteptr;
2053       L_operand(label_byteptr);
2054 
2055       jitc_get_valuesr_1();
2056       jit_movr_p(JIT_R2,JIT_R0);
2057       jitc_pop_stack();
2058       rf1 = jit_beqr_p(jit_forward(),JIT_R0,JIT_R2);
2059       jitc_bcjmpi(label_byteptr - CODEPTR);
2060       jit_patch(rf1);
2061 
2062       goto next_byte;
2063     }
2064     CASE cod_jmpifeqto: {       /* (JMPIFEQTO n label) */
2065       jit_insn *rf1;
2066       uintL n;
2067       const uintB* label_byteptr;
2068       U_operand(n);
2069       L_operand(label_byteptr);
2070 
2071       jitc_get_cconsti(n);
2072       jit_movr_p(JIT_R2,JIT_R0);
2073       jitc_pop_stack();
2074       rf1 = jit_bner_p(jit_forward(),JIT_R0,JIT_R2);
2075       jitc_bcjmpi(label_byteptr - CODEPTR);
2076       jit_patch(rf1);
2077 
2078       goto next_byte;
2079     }
2080     CASE cod_jmpifnoteqto: {    /* (JMPIFNOTEQTO n label) */
2081       jit_insn *rf1;
2082       uintL n;
2083       const uintB* label_byteptr;
2084       U_operand(n);
2085       L_operand(label_byteptr);
2086 
2087       jitc_get_cconsti(n);
2088       jit_movr_p(JIT_R2,JIT_R0);
2089       jitc_pop_stack();
2090       rf1 = jit_beqr_p(jit_forward(),JIT_R0,JIT_R2);
2091       jitc_bcjmpi(label_byteptr - CODEPTR);
2092       jit_patch(rf1);
2093 
2094       goto next_byte;
2095     }
2096     CASE cod_jmphash: {         /* (JMPHASH n label) */
2097       jit_insn *rf1;
2098       const uintB* label_byteptr;
2099       uintL n;
2100       U_operand(n);
2101       const uintB *saved_byteptr = byteptr;
2102       L_operand(label_byteptr);
2103 
2104       jit_prepare(3);
2105       jit_movi_l(JIT_R0,false);
2106       jit_pusharg_p(JIT_R0);
2107       jitc_get_cconsti(n);
2108       jit_pusharg_p(JIT_R0);
2109       jitc_get_valuesr_1();
2110       jit_pusharg_p(JIT_R0);
2111       jit_finish(gethash);
2112       jit_retval(JIT_R2);
2113 
2114       rf1 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(nullobj));
2115       jitc_bcjmpi(label_byteptr - CODEPTR);
2116       jit_patch(rf1);
2117       jitc_fixnum2valr();
2118       jit_movr_p(JIT_R2,JIT_R0);
2119       jit_addi_p(JIT_R2,JIT_R2,(saved_byteptr - CODEPTR));
2120 
2121       jitc_bcjmpr();
2122 
2123       goto next_byte;
2124     }
2125     CASE cod_jmphashv: {        /* (JMPHASHV n label) */
2126       jit_insn *rf1;
2127       const uintB* label_byteptr;
2128       uintL n;
2129       U_operand(n);
2130       const uintB *saved_byteptr = byteptr;
2131       L_operand(label_byteptr);
2132 
2133       jit_prepare(3);
2134       jit_movi_l(JIT_R0,false);
2135       jit_pusharg_p(JIT_R0);
2136       jitc_get_cconsti(0);
2137       jit_movr_p(JIT_R2,JIT_R0);
2138       jitc_get_svecdatair(n);
2139       jit_pusharg_p(JIT_R0);
2140       jitc_get_valuesr_1();
2141       jit_pusharg_p(JIT_R0);
2142       jit_finish(gethash);
2143       jit_retval(JIT_R2);
2144 
2145       rf1 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(nullobj));
2146       jitc_bcjmpi(label_byteptr - CODEPTR);
2147       jit_patch(rf1);
2148       jitc_fixnum2valr();
2149       jit_movr_p(JIT_R2,JIT_R0);
2150       jit_addi_p(JIT_R2,JIT_R2,(saved_byteptr - CODEPTR));
2151 
2152       jitc_bcjmpr();
2153 
2154       goto next_byte;
2155     }
2156 #define jitc_save_backtrace_jsr(statement) {             \
2157       jit_addi_p(JIT_R0,JIT_FP,bt_here);                \
2158       jit_ldi_p(JIT_R1,&back_trace);                                    \
2159       jit_stxi_i (jit_field(struct backtrace_t, bt_next), JIT_R0, JIT_R1); \
2160       jit_ldr_p(JIT_R1,JIT_V1);                                         \
2161       jit_stxi_i (jit_field(struct backtrace_t, bt_function), JIT_R0, JIT_R1); \
2162       jit_ldi_p(JIT_R1,&(STACK));                                       \
2163       jit_stxi_i (jit_field(struct backtrace_t, bt_stack), JIT_R0, JIT_R1); \
2164       jit_movi_l(JIT_R1,-1);                                            \
2165       jit_stxi_i (jit_field(struct backtrace_t, bt_num_arg), JIT_R0, JIT_R1); \
2166       jit_sti_p(&back_trace, JIT_R0);                                   \
2167       statement;                                                        \
2168       jit_ldi_p(JIT_R0,&back_trace);                                    \
2169       jit_ldxi_p(JIT_R1, JIT_R0, jit_field(struct backtrace_t, bt_next)); \
2170       jit_sti_p(&back_trace, JIT_R1);                                   \
2171     }
2172     CASE cod_jsr: {             /* (JSR label) */
2173       const uintB* label_byteptr;
2174       L_operand(label_byteptr);
2175 
2176       jitc_check_stack();
2177       jitc_save_backtrace_jsr({
2178           jit_prepare(3);
2179           jit_ldr_p(JIT_R2,JIT_V1);
2180           jitc_get_fieldr(Closure,clos_codevec);
2181           jit_addi_p(JIT_R1,JIT_R0,TheSbvector(as_object(0))); /* codeptr */
2182           jit_addi_p(JIT_R0,JIT_R1,(label_byteptr - (uintB*)codeptr));
2183           jit_pusharg_p(JIT_R0);
2184           jit_pusharg_p(JIT_R1);
2185           jit_pusharg_p(JIT_R2);
2186           jit_finish(cclosure_run);
2187         });
2188       jitc_tag_unsafe();
2189       goto next_byte;
2190     }
2191     CASE cod_jsr_push: {        /* (JSR&PUSH label) */
2192       const uintB* label_byteptr;
2193       L_operand(label_byteptr);
2194 
2195       jitc_check_stack();
2196       jitc_save_backtrace_jsr({
2197           jit_prepare(3);
2198           jit_ldr_p(JIT_R2,JIT_V1);
2199           jitc_get_fieldr(Closure,clos_codevec);
2200           jit_addi_p(JIT_R1,JIT_R0,TheSbvector(as_object(0))); /* codeptr */
2201           jit_addi_p(JIT_R0,JIT_R1,(label_byteptr - (uintB*)codeptr));
2202           jit_pusharg_p(JIT_R0);
2203           jit_pusharg_p(JIT_R1);
2204           jit_pusharg_p(JIT_R2);
2205           jit_finish(cclosure_run);
2206         });
2207       jitc_get_valuesr_1();
2208       jit_movr_p(JIT_R2,JIT_R0);
2209       jitc_push_stackr();
2210       jitc_tag_unsafe();
2211       goto next_byte;
2212     }
2213     CASE cod_jmptail: {         /* (JMPTAIL m n label) */
2214       const uintB* label_byteptr;
2215       uintL m;
2216       uintL n;
2217       U_operand(m);
2218       U_operand(n);
2219       L_operand(label_byteptr);
2220 
2221       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2222       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
2223 
2224       jit_ldi_p(JIT_R0,&STACK);
2225       jitc_skip_stack_opir(JIT_V1,JIT_R0,m*sizeof(gcv_object_t));
2226       jitc_skip_stack_opir(JIT_R2,JIT_R0,n*sizeof(gcv_object_t));
2227 
2228       jit_movi_l(JIT_V2,m);
2229       jitc_repeat(JIT_V2,{
2230          #ifdef STACK_DOWN /* Because of postfix/prefix increment diffs */
2231           jit_subi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2232          #endif
2233           jitc_frame_nextx(JIT_V1);
2234           jit_str_p(JIT_R2,JIT_R0);
2235          #ifdef STACK_UP
2236           jit_addi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2237          #endif
2238         });
2239 
2240       /* REMOVE -- ALOT OF THINGS TO REMOVE HERE */
2241      #ifdef STACK_DOWN
2242       jit_subi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2243      #endif
2244       /* jit_sti_p(&closureptr,JIT_R2); */
2245       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
2246       jit_ldr_p(JIT_R0,JIT_V1);
2247       jit_str_p(JIT_R2,JIT_R0);
2248      #ifdef STACK_UP
2249       jit_addi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2250      #endif
2251       jit_sti_p(&STACK,JIT_R2);
2252 
2253       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
2254       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2255 
2256       jitc_bcjmpi(label_byteptr - CODEPTR);
2257 
2258       goto next_byte;
2259     }
2260     /* ------------------- (6) Environments and Closures ----------------- */
2261     CASE cod_venv: {            /* (VENV) */
2262       jitc_get_cconsti(0);
2263       jit_movr_p(JIT_R2,JIT_R0);
2264       jitc_set_valuesr_1();
2265 
2266       goto next_byte;
2267     }
2268     CASE cod_make_vector1_push: { /* (MAKE-VECTOR1&PUSH n) */
2269       uintL n;
2270       U_operand(n);
2271 
2272       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2273 
2274       jitc_get_valuesr_1();
2275       jit_movr_p(JIT_R2,JIT_R0);
2276       jitc_push_stackr();
2277       jit_prepare(1);
2278       jit_movi_l(JIT_R0,(n+1));
2279       jit_pusharg_p(JIT_R0);
2280       jit_finish(allocate_vector);
2281       jit_retval(JIT_V2);
2282       jit_movr_p(JIT_R2,JIT_V2);
2283       jitc_getptr_svecdatair(0);
2284       jit_movr_p(JIT_R2,JIT_R0);
2285       jitc_get_stacki(0);
2286       jit_str_p(JIT_R2,JIT_R0);
2287       jitc_getptr_stacki(0);
2288       jit_str_p(JIT_R0,JIT_V2);
2289 
2290       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2291 
2292       jitc_tag_unsafe();
2293       goto next_byte;
2294     }
2295     CASE cod_copy_closure: {    /* (COPY-CLOSURE m n) */
2296       uintL m;
2297       uintL n;
2298       U_operand(m);
2299       U_operand(n);
2300 
2301       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2302       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
2303 
2304       jitc_get_cconsti(m);
2305       jit_movr_p(JIT_R2,JIT_R0);
2306       jitc_push_stackr();
2307 
2308       /* Allocate closure */
2309       jit_prepare(2);
2310       jitc_getlenr(Cclosure);
2311       jit_pusharg_p(JIT_R0);
2312       jitc_get_fieldr(Cclosure,tfl);
2313       jit_rshi_i(JIT_R0,JIT_R0,8);
2314       jit_andi_ui(JIT_R0,JIT_R0,0xFF);
2315       jit_lshi_i(JIT_R0,JIT_R0,8);
2316       jit_addi_p(JIT_R0,JIT_R0,Rectype_Closure);
2317       jit_pusharg_p(JIT_R0);
2318       jit_finish(allocate_srecord_);
2319       jit_retval(JIT_V1);
2320       jit_movr_p(JIT_R2,JIT_V1);
2321       jit_stxi_p(jitc_var_c,JIT_FP,JIT_R2);
2322 
2323       /* Copy the closure */
2324       jitc_pop_stack(); /* oldclos */
2325       jit_movr_p(JIT_R2,JIT_R0);
2326       jitc_getlenr(Cclosure);
2327       jit_movr_p(JIT_V2,JIT_R0);
2328       jit_addi_p(JIT_V1, JIT_V1, TheCclosure(as_object(jit_ptr_field(Srecord, recdata)))); /* newclos */
2329       jit_addi_p(JIT_R2, JIT_R2, TheCclosure(as_object(jit_ptr_field(Srecord, recdata)))); /* oldclos */
2330       jitc_repeatp(JIT_V2,
2331                   jit_ldr_p(JIT_R1,JIT_R2);
2332                   jit_str_p(JIT_V1,JIT_R1);
2333                   jit_addi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2334                   jit_addi_p(JIT_V1,JIT_V1,sizeof(gcv_object_t));
2335                   );
2336 
2337       /* Copy stack to closure */
2338       jit_ldxi_p(JIT_R2,JIT_FP,jitc_var_c); /* oldclos */
2339       jitc_getptr_fieldr(Cclosure,clos_consts);
2340       jit_addi_p(JIT_R2,JIT_R0,n*sizeof(gcv_object_t)); /* newptr */
2341       jit_movi_l(JIT_V2,n);
2342       jitc_repeatp(JIT_V2,
2343                   jitc_pop_stack();
2344                   jit_subi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2345                   jit_str_p(JIT_R2,JIT_R0);
2346                   );
2347       jit_ldxi_p(JIT_R2,JIT_FP,jitc_var_c);
2348       jitc_set_valuesr_1();
2349 
2350       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
2351       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2352 
2353       jitc_tag_unsafe();
2354       goto next_byte;
2355     }
2356     CASE cod_copy_closure_push: { /* (COPY-CLOSURE&PUSH m n) */
2357       uintL m;
2358       uintL n;
2359       U_operand(m);
2360       U_operand(n);
2361 
2362       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2363       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
2364 
2365       jitc_get_cconsti(m);
2366       jit_movr_p(JIT_R2,JIT_R0);
2367       jitc_push_stackr();
2368 
2369       /* Allocate closure */
2370       jit_prepare(2);
2371       jitc_getlenr(Cclosure);
2372       jit_pusharg_p(JIT_R0);
2373       jitc_get_fieldr(Cclosure,tfl);
2374       jit_rshi_i(JIT_R0,JIT_R0,8);
2375       jit_andi_ui(JIT_R0,JIT_R0,0xFF);
2376       jit_lshi_i(JIT_R0,JIT_R0,8);
2377       jit_addi_p(JIT_R0,JIT_R0,Rectype_Closure);
2378       jit_pusharg_p(JIT_R0);
2379       jit_finish(allocate_srecord_);
2380       jit_retval(JIT_V1);
2381       jit_movr_p(JIT_R2,JIT_V1);
2382       jit_stxi_p(jitc_var_c,JIT_FP,JIT_R2);
2383 
2384       /* Copy the closure */
2385       jitc_pop_stack(); /* oldclos */
2386       jit_movr_p(JIT_R2,JIT_R0);
2387       jitc_getlenr(Cclosure);
2388       jit_movr_p(JIT_V2,JIT_R0);
2389       jit_addi_p(JIT_V1, JIT_V1, TheCclosure(as_object(jit_ptr_field(Srecord, recdata)))); /* newclos */
2390       jit_addi_p(JIT_R2, JIT_R2, TheCclosure(as_object(jit_ptr_field(Srecord, recdata)))); /* oldclos */
2391       jitc_repeatp(JIT_V2,
2392                   jit_ldr_p(JIT_R1,JIT_R2);
2393                   jit_str_p(JIT_V1,JIT_R1);
2394                   jit_addi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2395                   jit_addi_p(JIT_V1,JIT_V1,sizeof(gcv_object_t));
2396                   );
2397 
2398       /* Copy stack to closure */
2399       jit_ldxi_p(JIT_R2,JIT_FP,jitc_var_c); /* oldclos */
2400       jitc_getptr_fieldr(Cclosure,clos_consts);
2401       jit_addi_p(JIT_R2,JIT_R0,n*sizeof(gcv_object_t)); /* newptr */
2402       jit_movi_l(JIT_V2,n);
2403       jitc_repeatp(JIT_V2,
2404                   jitc_pop_stack();
2405                   jit_subi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2406                   jit_str_p(JIT_R2,JIT_R0);
2407                   );
2408       jit_ldxi_p(JIT_R2,JIT_FP,jitc_var_c);
2409       jitc_push_stackr();
2410 
2411       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
2412       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2413 
2414       jitc_tag_unsafe();
2415       goto next_byte;
2416     }
2417     /* ------------------- (7) Function Calls ----------------------- */
2418     CASE cod_call: {            /* (CALL k n) */
2419       uintC k;
2420       uintL n;
2421       U_operand(k);
2422       U_operand(n);
2423 
2424       jitc_funcall();
2425 
2426       jitc_tag_unsafe();
2427       goto next_byte;
2428     }
2429     CASE cod_call_push: {       /* (CALL&PUSH k n) */
2430       uintC k;
2431       uintL n;
2432       U_operand(k);
2433       U_operand(n);
2434 
2435       jitc_funcall();
2436       jitc_get_valuesr_1();
2437       jit_movr_p(JIT_R2,JIT_R0);
2438       jitc_push_stackr();
2439 
2440       jitc_tag_unsafe();
2441       goto next_byte;
2442     }
2443     CASE cod_call0: {           /* (CALL0 n) */
2444       uintL n;
2445       U_operand(n);
2446 
2447       jitc_funcall0();
2448 
2449       jitc_tag_unsafe();
2450       goto next_byte;
2451     }
2452     CASE cod_call1: {           /* (CALL1 n) */
2453       uintL n;
2454       U_operand(n);
2455 
2456       jitc_funcall1();
2457 
2458       jitc_tag_unsafe();
2459       goto next_byte;
2460     }
2461     CASE cod_call1_push: {      /* (CALL1&PUSH n) */
2462       uintL n;
2463       U_operand(n);
2464 
2465       jitc_funcall1();
2466       jitc_get_valuesr_1();
2467       jit_movr_p(JIT_R2,JIT_R0);
2468       jitc_push_stackr();
2469 
2470       jitc_tag_unsafe();
2471       goto next_byte;
2472     }
2473     CASE cod_call2: {           /* (CALL2 n) */
2474       uintL n;
2475       U_operand(n);
2476 
2477       jitc_funcall2();
2478 
2479       jitc_tag_unsafe();
2480       goto next_byte;
2481     }
2482     CASE cod_call2_push: {      /* (CALL2&PUSH n) */
2483       uintL n;
2484       U_operand(n);
2485 
2486       jitc_funcall2();
2487       jitc_get_valuesr_1();
2488       jit_movr_p(JIT_R2,JIT_R0);
2489       jitc_push_stackr();
2490 
2491       jitc_tag_unsafe();
2492       goto next_byte;
2493     }
2494     CASE cod_calls1: {          /* (CALLS1 n) */
2495       uintL n;
2496       B_operand(n);
2497 
2498       jitc_funcalls1();
2499 
2500       jitc_tag_unsafe();
2501       goto next_byte;
2502     }
2503     CASE cod_calls1_push: {     /* (CALLS1&PUSH n) */
2504       uintL n;
2505       B_operand(n);
2506 
2507       jitc_funcalls1();
2508       jitc_get_valuesr_1();
2509       jit_movr_p(JIT_R2,JIT_R0);
2510       jitc_push_stackr();
2511 
2512       jitc_tag_unsafe();
2513       goto next_byte;
2514     }
2515     CASE cod_calls2: {          /* (CALLS2 n) */
2516       uintL n;
2517       B_operand(n);
2518 
2519       jitc_funcalls2();
2520 
2521       jitc_tag_unsafe();
2522       goto next_byte;
2523     }
2524     CASE cod_calls2_push: {     /* (CALLS2&PUSH n) */
2525       uintL n;
2526       B_operand(n);
2527 
2528       jitc_funcalls2();
2529       jitc_get_valuesr_1();
2530       jit_movr_p(JIT_R2,JIT_R0);
2531       jitc_push_stackr();
2532 
2533       jitc_tag_unsafe();
2534       goto next_byte;
2535     }
2536     CASE cod_callsr: {          /* (CALLSR m n) */
2537       uintL m;
2538       uintL n;
2539       U_operand(m);
2540       B_operand(n);
2541 
2542       jitc_funcallsr();
2543 
2544       jitc_tag_unsafe();
2545       goto next_byte;
2546     }
2547     CASE cod_callsr_push: {     /* (CALLSR&PUSH m n) */
2548       uintL m;
2549       uintL n;
2550       U_operand(m);
2551       B_operand(n);
2552 
2553       jitc_funcallsr();
2554       jitc_get_valuesr_1();
2555       jit_movr_p(JIT_R2,JIT_R0);
2556       jitc_push_stackr();
2557 
2558       jitc_tag_unsafe();
2559       goto next_byte;
2560     }
2561     CASE cod_callc: {           /* (CALLC) */
2562       jitc_funcallc();
2563 
2564       jitc_tag_unsafe();
2565       goto next_byte;
2566     }
2567     CASE cod_callc_push: {      /* (CALLC&PUSH) */
2568       jitc_funcallc();
2569       jitc_get_valuesr_1();
2570       jit_movr_p(JIT_R2,JIT_R0);
2571       jitc_push_stackr();
2572 
2573       jitc_tag_unsafe();
2574       goto next_byte;
2575     }
2576     CASE cod_callckey: {        /* (CALLCKEY) */
2577       jitc_funcallckey();
2578 
2579       jitc_tag_unsafe();
2580       goto next_byte;
2581     }
2582     CASE cod_callckey_push: {   /* (CALLCKEY&PUSH) */
2583       jitc_funcallckey();
2584       jitc_get_valuesr_1();
2585       jit_movr_p(JIT_R2,JIT_R0);
2586       jitc_push_stackr();
2587 
2588       jitc_tag_unsafe();
2589       goto next_byte;
2590     }
2591     CASE cod_funcall: {         /* (FUNCALL n) */
2592       uintL n;
2593       U_operand(n);
2594 
2595       jit_prepare(2);
2596       jit_movi_l(JIT_R0,n);
2597       jit_pusharg_p(JIT_R0);
2598       jitc_get_stacki(n);
2599       jit_pusharg_p(JIT_R0);
2600       jit_finish(funcall);
2601       jitc_skip_stacki(1);
2602 
2603       jitc_tag_unsafe();
2604       goto next_byte;
2605     }
2606     CASE cod_funcall_push: {    /* (FUNCALL&PUSH n) */
2607       uintL n;
2608       U_operand(n);
2609 
2610       jit_prepare(2);
2611       jit_movi_l(JIT_R0,n);
2612       jit_pusharg_p(JIT_R0);
2613       jitc_get_stacki(n);
2614       jit_pusharg_p(JIT_R0);
2615       jit_finish(funcall);
2616       jitc_getptr_stacki(0);
2617       jit_movr_p(JIT_R1,JIT_R0);
2618       jitc_get_valuesr_1();
2619       jit_str_p(JIT_R1,JIT_R0);
2620 
2621       jitc_tag_unsafe();
2622       goto next_byte;
2623     }
2624     CASE cod_apply: {           /* (APPLY n) */
2625       uintL n;
2626       U_operand(n);
2627 
2628       jit_prepare(3);
2629       jitc_get_valuesr_1();
2630       jit_pusharg_p(JIT_R0);
2631       jit_movi_l(JIT_R0,n);
2632       jit_pusharg_p(JIT_R0);
2633       jitc_get_stacki(n);
2634       jit_pusharg_p(JIT_R0);
2635       jit_finish(apply);
2636       jitc_skip_stacki(1);
2637 
2638       jitc_tag_unsafe();
2639       goto next_byte;
2640     }
2641     CASE cod_apply_push: {      /* (APPLY&PUSH n) */
2642       uintL n;
2643       U_operand(n);
2644 
2645       jit_prepare(3);
2646       jitc_get_valuesr_1();
2647       jit_pusharg_p(JIT_R0);
2648       jit_movi_l(JIT_R0,n);
2649       jit_pusharg_p(JIT_R0);
2650       jitc_get_stacki(n);
2651       jit_pusharg_p(JIT_R0);
2652       jit_finish(apply);
2653       jitc_getptr_stacki(0);
2654       jit_movr_p(JIT_R1,JIT_R0);
2655       jitc_get_valuesr_1();
2656       jit_str_p(JIT_R1,JIT_R0);
2657 
2658       jitc_tag_unsafe();
2659       goto next_byte;
2660     }
2661   /* ------------------- (8) optional and Keyword-arguments -------------- */
2662     CASE cod_push_unbound: {    /* (PUSH-UNBOUND n) */
2663       uintC n;
2664       jit_insn* ref;
2665       U_operand(n);
2666 
2667       jit_movi_l(JIT_R2,n);
2668       jitc_repeat(JIT_R2,
2669                  jitc_push_stacki(as_oint(unbound));
2670                  );
2671 
2672       goto next_byte;
2673     }
2674     CASE cod_unlist: {          /* (UNLIST n m) */
2675       jit_insn *rf1=0,*rf2=0,*rf3=0;
2676       uintC n;
2677       uintC m;
2678       U_operand(n);
2679       U_operand(m);
2680 
2681       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2682       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
2683 
2684       jitc_get_valuesr_1();
2685       jit_movr_p(JIT_R2,JIT_R0);
2686       if (n > 0) {
2687         jit_movi_l(JIT_V2,n);
2688         jitc_repeatp(JIT_V2,
2689                     jitc_sym_atompr();
2690                     rf2 = jit_beqi_p(jit_forward(), JIT_R0, 1);
2691                     jitc_get_fieldr(Cons,cdr);
2692                     jit_movr_p(JIT_V1,JIT_R0);
2693                     jitc_get_fieldr(Cons,car);
2694                     jit_movr_p(JIT_R2,JIT_R0);
2695                     jitc_push_stackr();
2696                     jit_movr_p(JIT_R2,JIT_V1);
2697                     );
2698       }
2699 
2700       jitc_sym_atompr();
2701       rf1 = jit_beqi_p(jit_forward(), JIT_R0, 1);
2702       jit_prepare(1);
2703       jit_movi_l(JIT_R0,as_oint(S(lambda)));
2704       jit_pusharg_p(JIT_R0);
2705       jit_finish(error_apply_toomany);
2706 
2707       if (n > 0) {
2708         jit_patch(rf2);
2709         rf3 = jit_blei_p(jit_forward(),JIT_V2,m);
2710         jit_prepare(2);
2711         jit_pusharg_p(JIT_R2);
2712         jit_movi_l(JIT_R0,as_oint(S(lambda)));
2713         jit_pusharg_p(JIT_R0);
2714         jit_finish(error_apply_toofew);
2715         jit_patch(rf3);
2716         jitc_repeatp(JIT_V2,
2717                     jitc_push_stacki(as_oint(unbound));
2718                     );
2719       }
2720 
2721       jit_patch(rf1);
2722       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
2723       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2724 
2725       goto next_byte;
2726     }
2727     CASE cod_unliststar: {      /* (UNLIST* n m) */
2728       jit_insn *rf1=0,*rf2=0,*rf3=0;
2729       uintC n;
2730       uintC m;
2731       U_operand(n);
2732       U_operand(m);
2733 
2734       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2735       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
2736 
2737       jitc_get_valuesr_1();
2738       jit_movr_p(JIT_R2,JIT_R0);
2739       if (n > 0) {
2740         jit_movi_l(JIT_V2,n);
2741         jitc_repeatp(JIT_V2,
2742                     jitc_sym_atompr();
2743                     rf2 = jit_beqi_p(jit_forward(), JIT_R0, 1);
2744                     jitc_get_fieldr(Cons,cdr);
2745                     jit_movr_p(JIT_V1,JIT_R0);
2746                     jitc_get_fieldr(Cons,car);
2747                     jit_movr_p(JIT_R2,JIT_R0);
2748                     jitc_push_stackr();
2749                     jit_movr_p(JIT_R2,JIT_V1);
2750                     );
2751       }
2752 
2753       jitc_push_stackr();
2754       rf1 = jit_jmpi(jit_forward());
2755 
2756       if (n > 0) {
2757         jit_patch(rf2);
2758         rf3 = jit_blei_p(jit_forward(),JIT_V2,m);
2759         jit_prepare(2);
2760         jit_pusharg_p(JIT_R2);
2761         jit_movi_l(JIT_R0,as_oint(S(lambda)));
2762         jit_pusharg_p(JIT_R0);
2763         jit_finish(error_apply_toofew);
2764         jit_patch(rf3);
2765         jitc_repeatp(JIT_V2,
2766                     jitc_push_stacki(as_oint(unbound));
2767                     );
2768         jitc_push_stacki(as_oint(NIL));
2769       }
2770       jit_patch(rf1);
2771       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
2772       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2773 
2774       goto next_byte;
2775     }
2776     CASE cod_jmpifboundp: {     /* (JMPIFBOUNDP n label) */
2777       jit_insn *rf1;
2778       uintL n;
2779       const uintB* label_byteptr;
2780       U_operand(n);
2781       L_operand(label_byteptr);
2782 
2783       jitc_get_stacki(n);
2784       rf1 = jit_beqi_p(jit_forward(),JIT_R0,as_oint(unbound));
2785       jit_movr_p(JIT_R2,JIT_R0);
2786       jitc_set_valuesr_1();
2787       jitc_bcjmpi(label_byteptr - CODEPTR);
2788       jit_patch(rf1);
2789 
2790       goto next_byte;
2791     }
2792     CASE cod_boundp: {          /* (BOUNDP n) */
2793       jit_insn *rf1,*rf2;
2794       uintL n;
2795       U_operand(n);
2796 
2797       jitc_get_stacki(n);
2798       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(unbound));
2799       jitc_set_valuesi_1(as_oint(NIL));
2800       rf2 = jit_jmpi(jit_forward());
2801       jit_patch(rf1);
2802       jitc_set_valuesi_1(as_oint(T));
2803       jit_patch(rf2);
2804 
2805       goto next_byte;
2806     }
2807     CASE cod_unbound_nil: {     /* (UNBOUND->NIL n) */
2808       jit_insn *ref;
2809       uintL n;
2810       U_operand(n);
2811 
2812       jitc_get_stacki(n);
2813       ref = jit_bnei_p(jit_forward(),JIT_R0,as_oint(unbound));
2814       jitc_getptr_stacki(n);
2815       jit_movi_l(JIT_R1,as_oint(NIL));
2816       jit_str_p(JIT_R0,JIT_R1);
2817       jit_patch(ref);
2818 
2819       goto next_byte;
2820     }
2821     /* ------------------- (9) Treatment of multiple values ---------------- */
2822     CASE cod_values0: {         /* (VALUES0) */
2823       jitc_set_valuesi_1(as_oint(NIL));
2824       jitc_set_mvcounti(0);
2825 
2826       goto next_byte;
2827     }
2828     CASE cod_values1: {         /* (VALUES1) */
2829       jitc_set_mvcounti(1);
2830 
2831       goto next_byte;
2832     }
2833     CASE cod_stack_to_mv: {     /* (STACK-TO-MV n) */
2834       uintL n;
2835       U_operand(n);
2836       if (n >= mv_limit) GOTO_ERROR(error_toomany_values);
2837       if (n == 0) {
2838         jitc_rawset_valuesi_1(as_oint(NIL));
2839         jitc_set_mvcounti(0);
2840       } else {
2841         jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2842 
2843         jitc_set_mvcounti(n);
2844         jitc_getptr_valuesi(n);
2845         jit_movr_p(JIT_R2,JIT_R0);
2846         jit_movi_l(JIT_V2,n);
2847         jitc_repeatp(JIT_V2,
2848                     jitc_pop_stack();
2849                     jit_subi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2850                     jit_str_p(JIT_R2,JIT_R0);
2851                     );
2852         jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2853       }
2854 
2855       goto next_byte;
2856     }
2857     CASE cod_mv_to_stack: {     /* (MV-TO-STACK) */
2858       jit_insn *rf1, *rf2;
2859 
2860       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2861       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
2862 
2863       jitc_mv2stackx();
2864 
2865       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
2866       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2867 
2868       goto next_byte;
2869     }
2870     CASE cod_nv_to_stack: {     /* (NV-TO-STACK n) */
2871       jit_insn *rf1,*rf2,*rf3,*rf4,*rf5,*rf6,*rf7;
2872       uintL n;
2873       U_operand(n);
2874 
2875       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2876       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
2877 
2878       jit_movi_l(JIT_R2,n*sizeof(gcv_object_t));
2879       jitc_check_stackr();
2880 
2881       jit_movi_l(JIT_V2,n);
2882       rf1 = jit_beqi_p(jit_forward(),JIT_V2,0);
2883       jitc_get_valuesr_1();
2884       jit_movr_p(JIT_R2,JIT_R0);
2885       jitc_push_stackr();
2886 
2887       jit_subi_p(JIT_V2,JIT_V2,1);
2888       rf2 = jit_beqi_p(jit_forward(),JIT_V2,0);
2889 
2890       jitc_get_mvcountr();
2891       jit_movr_p(JIT_V1,JIT_R0);
2892       rf3 = jit_blei_ui(jit_forward(),JIT_V1,1);
2893       jit_subi_p(JIT_V1,JIT_V1,1);
2894 
2895       jitc_getptr_valuesi(1);
2896       jit_movr_p(JIT_R2,JIT_R0);
2897       rf4 = jit_get_label(); /* Infinite loop */
2898       jitc_ldpush_stackr();
2899 
2900       jit_addi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
2901       jit_subi_p(JIT_V2,JIT_V2,1);
2902       rf5 = jit_beqi_p(jit_forward(),JIT_V2,0);
2903       jit_subi_p(JIT_V1,JIT_V1,1);
2904       rf6 = jit_beqi_p(jit_forward(),JIT_V1,0);
2905       (void)jit_jmpi(rf4);
2906 
2907       jit_patch(rf3); /* nv_to_stack_fill */
2908       jit_patch(rf6);
2909       jitc_repeatp(JIT_V2,
2910                   jitc_push_stacki(as_oint(NIL));
2911                   );
2912 
2913       jit_patch(rf1); /* nv_to_stack_end */
2914       jit_patch(rf2);
2915       jit_patch(rf5);
2916       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
2917       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2918 
2919       goto next_byte;
2920     }
2921     CASE cod_mv_to_list: {      /* (MV-TO-LIST) */
2922       jit_insn *rf1;
2923 
2924       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2925       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
2926 
2927       jitc_mv2stackx();
2928       jitc_push_stacki(as_oint(NIL));
2929 
2930       jitc_get_mvcountr();
2931       jit_movr_p(JIT_V2,JIT_R0);
2932       rf1 = jit_beqi_p(jit_forward(),JIT_V2,0);
2933       jitc_repeatp(JIT_V2,
2934                   (void)jit_calli(allocate_cons);
2935                   jit_retval(JIT_R2);
2936 
2937                   jitc_getptr_fieldr(Cons,cdr);
2938                   jit_movr_p(JIT_V1,JIT_R0);
2939                   jitc_pop_stack();
2940                   jit_str_p(JIT_V1,JIT_R0);
2941                   jitc_getptr_fieldr(Cons,car);
2942                   jit_movr_p(JIT_V1,JIT_R0);
2943                   jitc_get_stacki(0);
2944                   jit_str_p(JIT_V1,JIT_R0);
2945                   jitc_getptr_stacki(0);
2946                   jit_str_p(JIT_R0,JIT_R2);
2947                   );
2948       jit_patch(rf1);
2949       jitc_pop_stack();
2950       jit_movr_p(JIT_R2,JIT_R0);
2951       jitc_set_valuesr_1();
2952 
2953       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
2954       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
2955 
2956       jitc_tag_unsafe();
2957       goto next_byte;
2958     }
2959     CASE cod_list_to_mv: {      /* (LIST-TO-MV) */
2960       jit_insn *rf1,*rf2,*rf3,*rf4,*rf5;
2961       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
2962       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
2963 
2964       jitc_get_valuesr_1();
2965       jit_movr_p(JIT_R2,JIT_R0);
2966       jitc_sym_atompr();
2967       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
2968       jitc_set_valuesi_1(as_oint(NIL));
2969       jit_movi_l(JIT_V2,1);
2970       rf2 = jit_jmpi(jit_forward());
2971       jit_patch(rf1); /* else */
2972 
2973       jitc_getptr_valuesi(0);
2974       jit_movr_p(JIT_V1,JIT_R0);
2975       jit_movi_l(JIT_V2,0);
2976       rf3 = jit_get_label();
2977       rf4 = jit_bnei_p(jit_forward(), JIT_V2,(mv_limit-1));
2978       jit_ldxi_p(JIT_R0,JIT_FP,jitc_var_b); /* closureptr */
2979       jit_ldr_p(JIT_R2,JIT_R0);
2980       jitc_push_stackr();
2981       jitc_errori(error_condition,"~S: too many return values");
2982       jit_patch(rf4);
2983       jitc_get_fieldr(Cons,car);
2984       jit_str_p(JIT_V1,JIT_R0);
2985       jitc_get_fieldr(Cons,cdr);
2986       jit_movr_p(JIT_R2,JIT_R0);
2987       jit_addi_p(JIT_V1,JIT_V1,sizeof(gcv_object_t));
2988       jit_addi_p(JIT_V2,JIT_V2,1);
2989       jitc_sym_conspr();
2990       jit_beqi_p(rf3, JIT_R0,1);
2991       jit_patch(rf2);
2992       rf5 = jit_beqi_p(jit_forward(),JIT_R2,as_oint(NIL));
2993       jit_prepare(2);
2994       jit_pusharg_p(JIT_R2);
2995       jit_movi_l(JIT_R0,as_oint(S(values_list)));
2996       jit_pusharg_p(JIT_R0);
2997       jit_finish(error_proper_list_dotted);
2998       jit_patch(rf5);
2999       jit_movr_p(JIT_R2,JIT_V2);
3000       jitc_set_mvcountr();
3001 
3002       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
3003       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3004 
3005       goto next_byte;
3006     }
3007     CASE cod_mvcallp: {         /* (MVCALLP) */
3008       jit_ldi_p(JIT_R2,&(STACK));
3009       jitc_push_spr();
3010       jitc_get_valuesr_1();
3011       jit_movr_p(JIT_R2,JIT_R0);
3012       jitc_push_stackr();
3013 
3014       goto next_byte;
3015     }
3016     CASE cod_mvcall: {          /* (MVCALL) */
3017       jit_insn *ref;
3018 
3019       jitc_pop_sp();
3020       jit_movr_p(JIT_R2,JIT_R0);
3021       jitc_frame_nextx(JIT_R2);
3022       jit_ldi_p(JIT_R1,&(STACK));
3023       jitc_get_scountr(JIT_R2,JIT_R1,JIT_R2);
3024 
3025       ref = jit_blei_ui(jit_forward(),JIT_R2,ca_limit_1);
3026       jit_movr_p(JIT_R2,JIT_R0);
3027       jitc_push_stackr();
3028       jitc_push_stacki(as_oint(S(multiple_value_call)));
3029       jitc_errori(program_error,"~S: too many arguments given to ~S");
3030       jit_patch(ref);
3031       jit_prepare(2);
3032       jit_pusharg_p(JIT_R2);
3033       jit_pusharg_p(JIT_R0);
3034       jit_finish(funcall);
3035 
3036       jitc_skip_stacki(1);
3037 
3038       jitc_tag_unsafe();
3039       goto next_byte;
3040     }
3041     /* ------------------- (10) BLOCK ----------------------- */
3042     CASE cod_block_open: {      /* (BLOCK-OPEN n label) */
3043       /* occupies 3 STACK-entries and 1 SP-jmp_buf-entry and 2 SP-entries */
3044       uintL n;
3045       sintL label_dist;
3046       U_operand(n);
3047       S_operand(label_dist);
3048       label_dist += byteptr - CODEPTR;
3049 
3050       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3051       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
3052 
3053       jitc_push_spi(label_dist);
3054       jit_movr_p(JIT_R2,JIT_V1);
3055       jitc_push_spr();
3056 
3057       (void)jit_calli(allocate_cons);
3058       jit_retval(JIT_V2);
3059 
3060       jitc_get_cconsti(n);
3061       jit_movr_p(JIT_V1,JIT_R0);
3062       jit_movr_p(JIT_R2,JIT_V2);
3063       jitc_getptr_fieldr(Cons,car);
3064       jit_str_p(JIT_R0,JIT_V1);
3065 
3066       jitc_push_stackr();
3067       jitc_alloc_jmpbuf();
3068       jit_movr_p(JIT_R2,JIT_R0);
3069 
3070       jitc_finish_eframex(CBLOCK,3,{
3071           /* Executed if catched a RETURN-FROM */
3072           jitc_free_jmpbuf();
3073           jitc_skip_stacki(2);
3074           jitc_pop_stack();
3075           jit_movr_p(JIT_R2,JIT_R0);
3076           jitc_getptr_fieldr(Cons,cdr);
3077           jit_movi_l(JIT_R1,as_oint(disabled));
3078           jit_str_p(JIT_R0,JIT_R1);
3079           jitc_pop_sp();
3080           jit_movr_p(JIT_V1,JIT_R0);
3081           jitc_skip_spi(1);
3082           jitc_bcjmpi(label_dist);
3083         },{
3084           jit_movr_p(JIT_R2,JIT_V2);
3085           jitc_getptr_fieldr(Cons,cdr);
3086           jit_ldi_p(JIT_R1,&(STACK));
3087           jit_str_p(JIT_R0,JIT_R1);
3088         });
3089       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
3090       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3091 
3092       jitc_tag_unsafe();
3093       goto next_byte;
3094     }
3095     CASE cod_block_close: {     /* (BLOCK-CLOSE) */
3096       /* unwind CBLOCK-Frame: */
3097       jitc_free_jmpbuf();
3098       jitc_skip_stacki(2);
3099       jitc_pop_stack();
3100       jit_movr_p(JIT_R2,JIT_R0);
3101       jitc_getptr_fieldr(Cons,cdr);
3102       jit_movi_l(JIT_R1,as_oint(disabled));
3103       jit_str_p(JIT_R0,JIT_R1);
3104       jitc_skip_spi(2);
3105 
3106       goto next_byte;
3107     }
3108     CASE cod_return_from: {     /* (RETURN-FROM n) */
3109       jit_insn *ref;
3110       uintL n;
3111       U_operand(n);
3112 
3113       jitc_get_cconsti(n);
3114       jit_movr_p(JIT_R2,JIT_R0);
3115 
3116       jitc_get_fieldr(Cons,cdr);
3117       ref = jit_bnei_p(jit_forward(),JIT_R0,as_oint(disabled));
3118       jit_prepare(1);
3119       jitc_get_fieldr(Cons,car);
3120       jit_pusharg_p(JIT_R0);
3121       jit_finish(error_block_left);
3122       jit_patch(ref);
3123       jit_prepare(1);
3124       jit_pusharg_p(JIT_R0);
3125       jit_finish(unwind_upto);
3126 
3127       goto next_byte;
3128     }
3129     CASE cod_return_from_i: {   /* (RETURN-FROM-I k1 k2 n) */
3130       jit_insn* ref;
3131       uintL k1;
3132       uintL k2;
3133       uintL n;
3134       U_operand(k1);
3135       U_operand(k2);
3136       U_operand(n);
3137 
3138       jitc_get_spi(k1+jmpbufsize*k2);
3139       jit_movr_p(JIT_R2,JIT_R0);
3140       jitc_get_framei(n);
3141       jit_movr_p(JIT_R2,JIT_R0);
3142 
3143       jitc_get_fieldr(Cons,cdr);
3144       ref = jit_bnei_p(jit_forward(),JIT_R0,as_oint(disabled));
3145       jit_prepare(1);
3146       jitc_get_fieldr(Cons,car);
3147       jit_pusharg_p(JIT_R0);
3148       jit_finish(error_block_left);
3149       jit_patch(ref);
3150       jit_prepare(1);
3151       jit_pusharg_p(JIT_R0);
3152       jit_finish(unwind_upto);
3153 
3154       goto next_byte;
3155     }
3156     /* ------------------- (11) TAGBODY ----------------------- */
3157     CASE cod_tagbody_open: {    /* (TAGBODY-OPEN n label1 ... labelm) */
3158       /* occupies 3+m STACK-Entries and 1 SP-jmp_buf-Entry and 1 SP-Entry */
3159       uintL n;
3160       U_operand(n);
3161       const uintB* old_byteptr = byteptr;
3162 
3163       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3164 
3165       (void)jit_calli(allocate_cons);
3166       jit_retval(JIT_V2);
3167 
3168       object tag_vector = TheCclosure(closure)->clos_consts[n];
3169       uintL m = Svector_length(tag_vector);
3170       jitc_check_stacki(m*sizeof(gcv_object_t));
3171 
3172       uintL count;
3173       dotimespL(count,m, {
3174           const uintB* label_byteptr;
3175           L_operand(label_byteptr);
3176           jitc_push_stacki(as_oint(fixnum(label_byteptr - CODEPTR)));
3177         });
3178 
3179       jitc_get_cconsti(n);
3180       jit_movr_p(JIT_R2,JIT_V2);
3181       jit_movr_p(JIT_V2,JIT_R0);
3182       jitc_getptr_fieldr(Cons,car);
3183       jit_str_p(JIT_R0,JIT_V2);
3184       jit_movr_p(JIT_V2,JIT_R2);
3185 
3186       jit_movr_p(JIT_R2,JIT_V1);
3187       jitc_push_spr();
3188 
3189       jit_movr_p(JIT_R2,JIT_V2);
3190       jitc_push_stackr();
3191       jitc_alloc_jmpbuf();
3192       jit_movr_p(JIT_R2,JIT_R0);
3193 
3194       jitc_finish_eframex(CTAGBODY,3,{
3195           /* Executed if (GO) is reached */
3196           jitc_get_valuesr_1(); /* n of label */
3197           jit_movr_p(JIT_R2,JIT_R0);
3198           jitc_posfixnum2valr();
3199           jit_movi_l(JIT_R1,m);
3200           jit_subr_p(JIT_R0,JIT_R1,JIT_R0);
3201           jit_addi_p(JIT_R2,JIT_R0,3);
3202           jitc_get_stackr();
3203           jit_movr_p(JIT_R2,JIT_R0);
3204           jitc_posfixnum2valr();
3205           byteptr = old_byteptr;
3206           uintL count;
3207           dotimespL(count,m, {
3208               jit_insn *rf1;
3209               const uintB* label_byteptr;
3210               L_operand(label_byteptr);
3211               rf1 = jit_bnei_p(jit_forward(),JIT_R0,label_byteptr - CODEPTR);
3212               jitc_bcjmpi(label_byteptr - CODEPTR);
3213               jit_patch(rf1);
3214             });
3215         },{
3216           jit_movr_p(JIT_R2,JIT_V2);
3217           jitc_getptr_fieldr(Cons,cdr);
3218           jit_ldi_p(JIT_R1,&(STACK));
3219           jit_str_p(JIT_R0,JIT_R1);
3220         });
3221 
3222       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3223 
3224       jitc_tag_unsafe();
3225       goto next_byte;
3226     }
3227     CASE cod_tagbody_close_nil: { /* (TAGBODY-CLOSE-NIL) */
3228       jitc_set_valuesi_1(as_oint(NIL));
3229 
3230       jitc_free_jmpbuf();
3231       jitc_get_stacki(2);
3232       jit_movr_p(JIT_R2,JIT_R0);
3233       jitc_getptr_fieldr(Cons,cdr);
3234       jit_movi_l(JIT_R1,as_oint(disabled));
3235       jit_str_p(JIT_R0,JIT_R1);
3236       jitc_get_fieldr(Cons,car);
3237       jit_movr_p(JIT_R2,JIT_R0);
3238       jitc_getlen_svecr();
3239       jit_addi_p(JIT_R0,JIT_R0,3);
3240       jit_movr_p(JIT_R2,JIT_R0);
3241       jitc_skip_stackr();
3242       jitc_skip_spi(1);
3243 
3244       goto next_byte;
3245     }
3246     CASE cod_tagbody_close: {   /* (TAGBODY-CLOSE) */
3247       /* unwind CTAGBODY-Frame: */
3248       jitc_free_jmpbuf();
3249       jitc_get_stacki(2);
3250       jit_movr_p(JIT_R2,JIT_R0);
3251       jitc_getptr_fieldr(Cons,cdr);
3252       jit_movi_l(JIT_R1,as_oint(disabled));
3253       jit_str_p(JIT_R0,JIT_R1);
3254       jitc_get_fieldr(Cons,car);
3255       jit_movr_p(JIT_R2,JIT_R0);
3256       jitc_getlen_svecr();
3257       jit_addi_p(JIT_R0,JIT_R0,3);
3258       jit_movr_p(JIT_R2,JIT_R0);
3259       jitc_skip_stackr();
3260       jitc_skip_spi(1);
3261 
3262       goto next_byte;
3263     }
3264     CASE cod_go: {              /* (GO n l) */
3265       jit_insn *rf1, *rf2, *rf3;
3266       uintL n;
3267       uintL l;
3268       U_operand(n);
3269       U_operand(l);
3270 
3271       jitc_get_cconsti(n);
3272       jit_movr_p(JIT_R2,JIT_R0);
3273 
3274       jitc_get_fieldr(Cons,cdr);
3275       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(disabled));
3276       jitc_get_fieldr(Cons,car);
3277       jit_movr_p(JIT_R2,JIT_R0);
3278       jitc_push_stackr();
3279       jitc_get_svecdatair(l);
3280       jit_movr_p(JIT_R2,JIT_R0);
3281       jitc_push_stackr();
3282       jitc_push_stacki(as_oint(S(go)));
3283       jitc_errori(control_error,"(~S ~S): the tagbody of the tags ~S has already been left");
3284       jit_patch(rf1);
3285 
3286       jit_movr_p(JIT_R2,JIT_R0);
3287       jit_movr_p(JIT_V2,JIT_R0);
3288       jitc_get_framei(0);
3289       jit_movr_p(JIT_R2,JIT_R0);
3290       jitc_get_framecoder();
3291       rf2 = jit_bnei_p(jit_forward(),JIT_R0,CTAGBODY_frame_info);
3292       jitc_set_valuesi_1(as_oint(fixnum(1+l)));
3293       rf3 = jit_jmpi(jit_forward());
3294       jit_patch(rf2);
3295       jitc_get_framei(frame_bindings+2*l+1);
3296       jit_movr_p(JIT_R2,JIT_R0);
3297       jitc_set_valuesr_1();
3298 
3299       jit_patch(rf3);
3300       jit_prepare(1);
3301       jit_pusharg_p(JIT_V2);
3302       jit_finish(unwind_upto);
3303 
3304       goto next_byte;
3305     }
3306     CASE cod_go_i: {            /* (GO-I k1 k2 n l) */
3307       jit_insn* ref;
3308       uintL k1;
3309       uintL k2;
3310       uintL n;
3311       uintL l;
3312       U_operand(k1);
3313       U_operand(k2);
3314       U_operand(n);
3315       U_operand(l);
3316 
3317       jitc_get_spi(k1+jmpbufsize*k2);
3318       jit_movr_p(JIT_R2,JIT_R0);
3319       jitc_get_framei(n);
3320       jit_movr_p(JIT_R2,JIT_R0);
3321 
3322       jitc_get_fieldr(Cons,cdr);
3323       ref = jit_bnei_p(jit_forward(),JIT_R0,as_oint(disabled));
3324       jitc_get_fieldr(Cons,car);
3325       jit_movr_p(JIT_R2,JIT_R0);
3326       jitc_push_stackr();
3327       jitc_get_svecdatair(l);
3328       jit_movr_p(JIT_R2,JIT_R0);
3329       jitc_push_stackr();
3330       jitc_push_stacki(as_oint(S(go)));
3331       jitc_errori(control_error,"(~S ~S): the tagbody of the tags ~S has already been left");
3332       jit_patch(ref);
3333 
3334       jitc_set_valuesi_1(as_oint(fixnum(1+l)));
3335 
3336       jit_prepare(1);
3337       jit_pusharg_p(JIT_R0);
3338       jit_finish(unwind_upto);
3339 
3340       goto next_byte;
3341     }
3342     /* ------------------- (12) CATCH and THROW ----------------------- */
3343     CASE cod_catch_open: {      /* (CATCH-OPEN label) */
3344       /* occupies 3 STACK-Entries and 1 SP-jmp_buf-Entry and 2 SP-Entries*/
3345       const uintB* label_byteptr;
3346       L_operand(label_byteptr);
3347 
3348       jitc_push_spi(label_byteptr - CODEPTR);
3349       jit_movr_p(JIT_R2,JIT_V1);
3350       jitc_push_spr();
3351 
3352       jitc_get_valuesr_1();
3353       jit_movr_p(JIT_R2,JIT_R0);
3354       jitc_push_stackr();
3355       jitc_alloc_jmpbuf();
3356       jit_movr_p(JIT_R2,JIT_R0);
3357 
3358       jitc_finish_eframex(CATCH,3,{
3359           /* Executed if (throw) is caught */
3360           jitc_free_jmpbuf();
3361           jitc_skip_stacki(3);
3362 
3363           jitc_skip_spi(2);
3364           jitc_bcjmpi(label_byteptr - CODEPTR);
3365         },{
3366         });
3367 
3368       goto next_byte;
3369     }
3370     CASE cod_catch_close: {     /* (CATCH-CLOSE) */
3371       jitc_free_jmpbuf();
3372       jitc_skip_spi(2);
3373       jitc_skip_stacki(3);
3374 
3375       goto next_byte;
3376     }
3377     CASE cod_throw: {           /* (THROW) */
3378       jitc_pop_stack();
3379       jit_movr_p(JIT_R2,JIT_R0);
3380       jit_prepare(1);
3381       jit_pusharg_p(JIT_R2);
3382       jit_finish(throw_to);
3383 
3384       jitc_push_stackr();
3385       jitc_push_stacki(as_oint(S(throw)));
3386       jitc_errori(control_error,"~S: there is no CATCHer for tag ~S");
3387 
3388       goto next_byte;
3389     }
3390     /* ------------------- (13) UNWIND-PROTECT ----------------------- */
3391     CASE cod_uwp_open: {        /* (UNWIND-PROTECT-OPEN label) */
3392       /* occupies 2 STACK-Entries and 1 SP-jmp_buf-Entry and 2 SP-Entries */
3393       const uintB* label_byteptr;
3394       L_operand(label_byteptr);
3395 
3396       jitc_push_spi(label_byteptr - CODEPTR);
3397       jit_movr_p(JIT_R2,JIT_R0);
3398       jitc_push_spr();
3399 
3400       jitc_alloc_jmpbuf();
3401       jit_movr_p(JIT_R2,JIT_R0);
3402 
3403       jitc_finish_eframex(UNWIND_PROTECT,2,{
3404           /* Executed if a (throw) is caught */
3405           jitc_free_jmpbuf();
3406           jitc_skip_stacki(2);
3407 
3408           jitc_skip_spi(2);
3409           jit_ldi_p(JIT_R2,&unwind_protect_to_save.fun);
3410           jitc_push_spr();
3411           jit_ldi_p(JIT_R2,&unwind_protect_to_save.upto_frame);
3412           jitc_push_spr();
3413           jit_ldi_p(JIT_R2,&STACK);
3414           jitc_push_spr();
3415 
3416           jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3417           jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
3418           jitc_mv2stackx();
3419           jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
3420           jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3421 
3422           jitc_bcjmpi(label_byteptr - CODEPTR);
3423         },{
3424         });
3425 
3426       goto next_byte;
3427     }
3428     CASE cod_uwp_normal_exit: { /* (UNWIND-PROTECT-NORMAL-EXIT) */
3429       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3430       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
3431 
3432       jitc_free_jmpbuf();
3433       jitc_skip_spi(2);
3434       jitc_skip_stacki(2);
3435 
3436       jitc_push_spi(NULL);
3437       jitc_push_spi(NULL);
3438       jit_ldi_p(JIT_R2,&STACK);
3439       jitc_push_spr();
3440 
3441       jitc_mv2stackx();
3442 
3443       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
3444       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3445 
3446       goto next_byte;
3447     }
3448     CASE cod_uwp_close: {       /* (UNWIND-PROTECT-CLOSE) */
3449       jit_insn *rf1;
3450 
3451       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3452 
3453       jitc_pop_sp(); /* oldSTACK */
3454       jit_ldi_p(JIT_R1,&STACK);
3455       jitc_get_scountr(JIT_R2,JIT_R1,JIT_R0);
3456 
3457       rf1 = jit_blti_p(jit_forward(),JIT_R2,mv_limit);
3458       jit_ldr_p(JIT_R2,JIT_V1);
3459       jitc_push_stackr();
3460       jitc_errori(error_condition,"~S: too many return values");
3461       jit_patch(rf1);
3462       /* Stack to MV */
3463       jit_movr_p(JIT_V2,JIT_R2);
3464       jitc_set_mvcountr();
3465       jitc_getptr_valuesr_1();
3466       jit_movi_l(JIT_R1,as_oint(NIL));
3467       jit_str_p(JIT_R0,JIT_R1);
3468       rf1 = jit_beqi_p(jit_forward(),JIT_V2,0);
3469       jitc_getptr_valuesr();
3470       jit_movr_p(JIT_R2,JIT_R0);
3471       jitc_repeatp(JIT_V2,{
3472           jitc_pop_stack();
3473           jit_subi_p(JIT_R2,JIT_R2,sizeof(gcv_object_t));
3474           jit_str_p(JIT_R2,JIT_R0);
3475         });
3476       jit_patch(rf1);
3477 
3478       jitc_pop_sp();
3479       jit_movr_p(JIT_R2,JIT_R0); /* arg */
3480       jitc_pop_sp(); /* fun */
3481       rf1 = jit_beqi_p(jit_forward(),JIT_R0,NULL);
3482       jit_prepare(1);
3483       jit_pusharg_p(JIT_R2);
3484       jit_finishr(JIT_R0);
3485       jitc_notreached();
3486       jit_patch(rf1);
3487       rf1 = jit_beqi_p(jit_forward(),JIT_R2,NULL);
3488       jitc_bcjmpr();
3489       jit_patch(rf1);
3490       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3491 
3492       goto next_byte;
3493     }
3494     CASE cod_uwp_cleanup: {     /* (UNWIND-PROTECT-CLEANUP) */
3495       /* this is executed, if within the same Closure an execution
3496          of the Cleanup-Code is necessary.
3497          closure remains, byteptr:=label_byteptr : */
3498       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3499       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
3500 
3501       jitc_get_spi(jmpbufsize+1);
3502       jit_stxi_p(jitc_var_c,JIT_FP,JIT_R0);
3503 
3504       jitc_free_jmpbuf();
3505       jitc_skip_spi(2);
3506       jitc_skip_stacki(2);
3507 
3508       jitc_push_spi(NULL);
3509       jitc_push_spi(byteptr - CODEPTR);
3510       jit_ldi_p(JIT_R2,&(STACK));
3511       jitc_push_spr();
3512 
3513       jitc_mv2stackx();
3514 
3515       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
3516       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3517 
3518       jit_ldxi_p(JIT_R2,JIT_FP,jitc_var_c);
3519 
3520       jitc_bcjmpr();
3521 
3522       goto next_byte;
3523     }
3524     /* ------------------- (14) HANDLER-BIND ----------------------- */
3525     CASE cod_handler_open: {    /* (HANDLER-OPEN n) */
3526       /* occupies 4 STACK-Entries */
3527       uintL n;
3528       U_operand(n);
3529 
3530       jitc_get_cconsti(n);
3531       jit_movr_p(JIT_R2,JIT_R0);
3532       jitc_push_stackr();
3533       jit_ldr_p(JIT_R2,JIT_V1);
3534       jitc_push_stackr();
3535       jitc_getptr_spi(0);
3536       jit_movr_p(JIT_R2,JIT_R0);
3537       jitc_push_stackr();
3538       jitc_finish_framer(HANDLER,4);
3539 
3540       goto next_byte;
3541     }
3542     CASE cod_handler_begin_push: { /* (HANDLER-BEGIN&PUSH) */
3543       jit_insn *rf1;
3544       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3545 
3546       jit_ldi_p(JIT_R2,&handler_args.spdepth);
3547       jitc_get_fieldr(Cons,car);
3548       jit_movr_p(JIT_R2,JIT_R0);
3549       jitc_posfixnum2valr();
3550       jit_movr_p(JIT_V2,JIT_R0);
3551 
3552       jit_ldi_p(JIT_R2,&handler_args.spdepth);
3553       jitc_get_fieldr(Cons,cdr);
3554       jit_movr_p(JIT_R2,JIT_R0);
3555       jitc_posfixnum2valr();
3556       jit_muli_ul(JIT_R0,JIT_R0,jmpbufsize);
3557       jit_addr_p(JIT_V2,JIT_V2,JIT_R0);
3558 
3559       rf1 = jit_blei_p(jit_forward(),JIT_V2,0);
3560       jit_ldi_p(JIT_R2,&handler_args.sp);
3561       jit_lshi_ul(JIT_R0,JIT_V2,sizeof(SPint*)/2);
3562       jit_addr_p(JIT_R2,JIT_R2,JIT_R0);
3563 
3564       jitc_repeatp(JIT_V2,
3565                   jit_addi_p(JIT_R2,JIT_R2,-sizeof(SPint*));
3566                   jitc_ldpush_spr();
3567                   );
3568       jit_patch(rf1);
3569 
3570       jit_ldi_p(JIT_R2,&handler_args.stack);
3571       jitc_push_spr();
3572       jit_ldi_p(JIT_R2,&handler_args.condition);
3573       jitc_set_valuesr_1();
3574       jitc_push_stackr();
3575 
3576       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3577 
3578       goto next_byte;
3579     }
3580     /* ------------------- (15) a few Functions ----------------------- */
3581     CASE cod_not: {             /* (NOT) */
3582       jit_insn *rf1,*rf2;
3583 
3584       jitc_get_valuesr_1();
3585 
3586       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(NIL));
3587       jitc_set_valuesi_1(as_oint(T));
3588       rf2 = jit_jmpi(jit_forward());
3589       jit_patch(rf1);
3590       jitc_set_valuesi_1(as_oint(NIL));
3591       jit_patch(rf2);
3592 
3593       goto next_byte;
3594     }
3595     CASE cod_eq: {              /* (EQ) */
3596       jit_insn *rf1,*rf2;
3597 
3598       jitc_pop_stack();
3599       jit_movr_p(JIT_R2,JIT_R0);
3600       jitc_get_valuesr_1();
3601 
3602       rf1 = jit_beqr_p(jit_forward(),JIT_R2,JIT_R0);
3603       jitc_set_valuesi_1(as_oint(NIL));
3604       rf2 = jit_jmpi(jit_forward());
3605       jit_patch(rf1);
3606       jitc_set_valuesi_1(as_oint(T));
3607       jit_patch(rf2);
3608 
3609       goto next_byte;
3610     }
3611     CASE cod_car: {             /* (CAR) */
3612       jit_insn *rf1,*rf2,*rf3,*rf4;
3613       jitc_get_valuesr_1();
3614       jit_movr_p(JIT_R2,JIT_R0);
3615 
3616       jitc_sym_conspr();
3617       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
3618       jitc_get_fieldr(Cons,car);
3619       jit_movr_p(JIT_R2,JIT_R0);
3620       jitc_set_valuesr_1();
3621       rf2 = jit_jmpi(jit_forward());
3622       jit_patch(rf1);
3623       rf3 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(NIL));
3624       rf4 = jit_jmpi(jit_forward());
3625       jit_patch(rf3);
3626       jitc_save_backtrace3(as_oint(L(car)), STACK, -1, -1,{
3627           jit_prepare(1);
3628           jit_pusharg_p(JIT_R2);
3629           jit_finish(error_list);
3630         });
3631 
3632       jit_patch(rf2);
3633       jit_patch(rf4);
3634       jitc_set_mvcounti(1);
3635 
3636       goto next_byte;
3637     }
3638     CASE cod_car_push: {        /* (CAR&PUSH) */
3639       jit_insn *rf1,*rf2,*rf3,*rf4;
3640 
3641       jitc_get_valuesr_1();
3642       jit_movr_p(JIT_R2,JIT_R0);
3643 
3644       jitc_sym_conspr();
3645       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
3646       jitc_get_fieldr(Cons,car);
3647       jit_movr_p(JIT_R2,JIT_R0);
3648       jitc_push_stackr();
3649       rf2 = jit_jmpi(jit_forward());
3650       jit_patch(rf1);
3651       rf3 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(NIL));
3652       jitc_push_stackr();
3653       rf4 = jit_jmpi(jit_forward());
3654       jit_patch(rf3);
3655       jitc_save_backtrace3(as_oint(L(car)), STACK, -1, -1,{
3656           jit_prepare(1);
3657           jit_pusharg_p(JIT_R2);
3658           jit_finish(error_list);
3659         });
3660 
3661       jit_patch(rf2);
3662       jit_patch(rf4);
3663 
3664       goto next_byte;
3665     }
3666     CASE cod_load_car_push: {   /* (LOAD&CAR&PUSH n) */
3667       uintL n;
3668       U_operand(n);
3669       jit_insn *rf1,*rf2,*rf3,*rf4;
3670 
3671       jitc_get_stacki(n);
3672       jit_movr_p(JIT_R2,JIT_R0);
3673 
3674       jitc_sym_conspr();
3675       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
3676       jitc_get_fieldr(Cons,car);
3677       jit_movr_p(JIT_R2,JIT_R0);
3678       jitc_push_stackr();
3679       rf2 = jit_jmpi(jit_forward());
3680       jit_patch(rf1);
3681       rf3 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(NIL));
3682       jitc_push_stackr();
3683       rf4 = jit_jmpi(jit_forward());
3684       jit_patch(rf3);
3685       jitc_save_backtrace3(as_oint(L(car)), STACK, -1, -1,{
3686           jit_prepare(1);
3687           jit_pusharg_p(JIT_R2);
3688           jit_finish(error_list);
3689         });
3690 
3691       jit_patch(rf2);
3692       jit_patch(rf4);
3693 
3694       goto next_byte;
3695     }
3696     CASE cod_load_car_store: {  /* (LOAD&CAR&STORE m n) */
3697       uintL m;
3698       uintL n;
3699       U_operand(m);
3700       U_operand(n);
3701       jit_insn *rf1,*rf2,*rf3,*rf4;
3702 
3703       jitc_get_stacki(m);
3704       jit_movr_p(JIT_R2,JIT_R0);
3705 
3706       jitc_sym_conspr();
3707       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
3708       jitc_get_fieldr(Cons,car);
3709       jit_movr_p(JIT_R2,JIT_R0);
3710       jitc_set_valuesr_1();
3711       jitc_getptr_stacki(n);
3712       jit_str_p(JIT_R0,JIT_R2);
3713       rf2 = jit_jmpi(jit_forward());
3714       jit_patch(rf1);
3715       rf3 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(NIL));
3716       jitc_set_valuesr_1();
3717       jitc_getptr_stacki(n);
3718       jit_str_p(JIT_R0,JIT_R2);
3719       rf4 = jit_jmpi(jit_forward());
3720       jit_patch(rf3);
3721       jitc_save_backtrace3(as_oint(L(car)), STACK, -1, -1,{
3722           jit_prepare(1);
3723           jit_pusharg_p(JIT_R2);
3724           jit_finish(error_list);
3725         });
3726 
3727       jit_patch(rf2);
3728       jit_patch(rf4);
3729       jitc_set_mvcounti(1);
3730 
3731       goto next_byte;
3732     }
3733     CASE cod_cdr: {             /* (CDR) */
3734       jit_insn *rf1,*rf2,*rf3,*rf4;
3735       jitc_get_valuesr_1();
3736       jit_movr_p(JIT_R2,JIT_R0);
3737 
3738       jitc_sym_conspr();
3739       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
3740       jitc_get_fieldr(Cons,cdr);
3741       jit_movr_p(JIT_R2,JIT_R0);
3742       jitc_set_valuesr_1();
3743       rf2 = jit_jmpi(jit_forward());
3744       jit_patch(rf1);
3745       rf3 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(NIL));
3746       rf4 = jit_jmpi(jit_forward());
3747       jit_patch(rf3);
3748       jitc_save_backtrace3(as_oint(L(cdr)), STACK, -1, -1,{
3749           jit_prepare(1);
3750           jit_pusharg_p(JIT_R2);
3751           jit_finish(error_list);
3752         });
3753 
3754       jit_patch(rf2);
3755       jit_patch(rf4);
3756       jitc_set_mvcounti(1);
3757 
3758       goto next_byte;
3759     }
3760     CASE cod_cdr_push: {        /* (CDR&PUSH) */
3761       jit_insn *rf1,*rf2,*rf3,*rf4;
3762 
3763       jitc_get_valuesr_1();
3764       jit_movr_p(JIT_R2,JIT_R0);
3765 
3766       jitc_sym_conspr();
3767       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
3768       jitc_get_fieldr(Cons,cdr);
3769       jit_movr_p(JIT_R2,JIT_R0);
3770       jitc_push_stackr();
3771       rf2 = jit_jmpi(jit_forward());
3772       jit_patch(rf1);
3773       rf3 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(NIL));
3774       jitc_push_stackr();
3775       rf4 = jit_jmpi(jit_forward());
3776       jit_patch(rf3);
3777       jitc_save_backtrace3(as_oint(L(cdr)), STACK, -1, -1,{
3778           jit_prepare(1);
3779           jit_pusharg_p(JIT_R2);
3780           jit_finish(error_list);
3781         });
3782 
3783       jit_patch(rf2);
3784       jit_patch(rf4);
3785 
3786       goto next_byte;
3787     }
3788     CASE cod_load_cdr_push: {   /* (LOAD&CDR&PUSH n) */
3789       uintL n;
3790       U_operand(n);
3791       jit_insn *rf1,*rf2,*rf3,*rf4;
3792 
3793       jitc_get_stacki(n);
3794       jit_movr_p(JIT_R2,JIT_R0);
3795 
3796       jitc_sym_conspr();
3797       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
3798       jitc_get_fieldr(Cons,cdr);
3799       jit_movr_p(JIT_R2,JIT_R0);
3800       jitc_push_stackr();
3801       rf2 = jit_jmpi(jit_forward());
3802       jit_patch(rf1);
3803       rf3 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(NIL));
3804       jitc_push_stackr();
3805       rf4 = jit_jmpi(jit_forward());
3806       jit_patch(rf3);
3807       jitc_save_backtrace3(as_oint(L(cdr)), STACK, -1, -1,{
3808           jit_prepare(1);
3809           jit_pusharg_p(JIT_R2);
3810           jit_finish(error_list);
3811         });
3812 
3813       jit_patch(rf2);
3814       jit_patch(rf4);
3815 
3816       goto next_byte;
3817     }
3818     CASE cod_load_cdr_store: {  /* (LOAD&CDR&STORE n) */
3819       uintL n;
3820       U_operand(n);
3821       jit_insn *rf1,*rf2,*rf3,*rf4;
3822 
3823       jitc_get_stacki(n);
3824       jit_movr_p(JIT_R2,JIT_R0);
3825 
3826       jitc_sym_conspr();
3827       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
3828       jitc_get_fieldr(Cons,cdr);
3829       jit_movr_p(JIT_R2,JIT_R0);
3830       jitc_set_valuesr_1();
3831       jitc_getptr_stacki(n);
3832       jit_str_p(JIT_R0,JIT_R2);
3833       rf2 = jit_jmpi(jit_forward());
3834       jit_patch(rf1);
3835       rf3 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(NIL));
3836       jitc_set_valuesr_1();
3837       jitc_getptr_stacki(n);
3838       jit_str_p(JIT_R0,JIT_R2);
3839       rf4 = jit_jmpi(jit_forward());
3840       jit_patch(rf3);
3841       jitc_save_backtrace3(as_oint(L(cdr)), STACK, -1, -1,{
3842           jit_prepare(1);
3843           jit_pusharg_p(JIT_R2);
3844           jit_finish(error_list);
3845         });
3846 
3847       jit_patch(rf2);
3848       jit_patch(rf4);
3849       jitc_set_mvcounti(1);
3850 
3851       goto next_byte;
3852     }
3853     CASE cod_cons: {            /* (CONS) */
3854       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3855 
3856       jitc_get_valuesr_1();
3857       jit_movr_p(JIT_R2,JIT_R0);
3858       jitc_push_stackr();
3859 
3860       (void)jit_calli(allocate_cons);
3861       jit_retval(JIT_V2);
3862 
3863       jit_movr_p(JIT_R2,JIT_V2);
3864       jitc_getptr_fieldr(Cons,cdr);
3865       jit_movr_p(JIT_R2,JIT_R0);
3866       jitc_pop_stack();
3867       jit_str_p(JIT_R2,JIT_R0);
3868 
3869       jit_movr_p(JIT_R2,JIT_V2);
3870       jitc_getptr_fieldr(Cons,car);
3871       jit_movr_p(JIT_R2,JIT_R0);
3872       jitc_pop_stack();
3873       jit_str_p(JIT_R2,JIT_R0);
3874 
3875       jit_movr_p(JIT_R2,JIT_V2);
3876       jitc_set_valuesr_1();
3877 
3878       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3879 
3880       jitc_tag_unsafe();
3881       goto next_byte;
3882     }
3883     CASE cod_cons_push: {       /* (CONS&PUSH) */
3884       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3885 
3886       jitc_get_valuesr_1();
3887       jit_movr_p(JIT_R2,JIT_R0);
3888       jitc_push_stackr();
3889 
3890       (void)jit_calli(allocate_cons);
3891       jit_retval(JIT_V2);
3892 
3893       jit_movr_p(JIT_R2,JIT_V2);
3894       jitc_getptr_fieldr(Cons,cdr);
3895       jit_movr_p(JIT_R2,JIT_R0);
3896       jitc_pop_stack();
3897       jit_str_p(JIT_R2,JIT_R0);
3898 
3899       jit_movr_p(JIT_R2,JIT_V2);
3900       jitc_getptr_fieldr(Cons,car);
3901       jit_movr_p(JIT_R2,JIT_R0);
3902       jitc_pop_stack();
3903       jit_str_p(JIT_R2,JIT_R0);
3904 
3905       jit_movr_p(JIT_R2,JIT_V2);
3906       jitc_push_stackr();
3907 
3908       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3909 
3910       jitc_tag_unsafe();
3911       goto next_byte;
3912     }
3913     CASE cod_load_cons_store: { /* (LOAD&CONS&STORE n) */
3914       uintL n;
3915       U_operand(n);
3916 
3917       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
3918 
3919       (void)jit_calli(allocate_cons);
3920       jit_retval(JIT_V2);
3921 
3922       jit_movr_p(JIT_R2,JIT_V2);
3923       jitc_getptr_fieldr(Cons,car);
3924       jit_movr_p(JIT_R2,JIT_R0);
3925       jitc_pop_stack();
3926       jit_str_p(JIT_R2,JIT_R0);
3927 
3928       jit_movr_p(JIT_R2,JIT_V2);
3929       jitc_getptr_fieldr(Cons,cdr);
3930       jit_movr_p(JIT_R2,JIT_R0);
3931       jitc_get_stacki(n);
3932       jit_str_p(JIT_R2,JIT_R0);
3933 
3934       jitc_getptr_stacki(n);
3935       jit_str_p(JIT_R0,JIT_V2);
3936       jit_movr_p(JIT_R2,JIT_V2);
3937       jitc_set_valuesr_1();
3938 
3939       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
3940 
3941       jitc_tag_unsafe();
3942       goto next_byte;
3943     }
3944     CASE cod_symbol_function: { /* (SYMBOL-FUNCTION) */
3945       jitc_get_valuesr_1();
3946       jit_movr_p(JIT_R2,JIT_R0);
3947 
3948       jitc_check_fdefx();
3949 
3950       jit_movr_p(JIT_R2,JIT_R0);
3951       jitc_set_valuesr_1();
3952 
3953       jitc_tag_unsafe();
3954       goto next_byte;
3955     }
3956     CASE cod_const_symbol_function: { /* (CONST&SYMBOL-FUNCTION n) */
3957       uintL n;
3958       U_operand(n);
3959 
3960       jitc_get_cconsti(n);
3961       jit_movr_p(JIT_R2,JIT_R0);
3962       jitc_check_fdefx();
3963       jit_movr_p(JIT_R2,JIT_R0);
3964       jitc_set_valuesr_1();
3965 
3966       jitc_tag_unsafe();
3967       goto next_byte;
3968     }
3969     CASE cod_const_symbol_function_push: { /* (CONST&SYMBOL-FUNCTION&PUSH n) */
3970       uintL n;
3971       U_operand(n);
3972 
3973       jitc_get_cconsti(n);
3974       jit_movr_p(JIT_R2,JIT_R0);
3975       jitc_check_fdefx();
3976       jit_movr_p(JIT_R2,JIT_R0);
3977       jitc_push_stackr();
3978 
3979       jitc_tag_unsafe();
3980       goto next_byte;
3981     }
3982     CASE cod_const_symbol_function_store: { /* (CONST&SYMBOL-FUNCTION&STORE n k) */
3983       uintL n;
3984       uintL k;
3985       U_operand(n);
3986       U_operand(k);
3987 
3988       jitc_get_cconsti(n);
3989       jit_movr_p(JIT_R2,JIT_R0);
3990       jitc_check_fdefx();
3991       jit_movr_p(JIT_R2,JIT_R0);
3992 
3993       jitc_getptr_stacki(k);
3994       jit_str_p(JIT_R0,JIT_R2);
3995       jitc_set_valuesr_1();
3996 
3997       jitc_tag_unsafe();
3998       goto next_byte;
3999     }
4000       /* object vec;object index; */
4001     CASE cod_svref: {           /* (SVREF) */
4002       jit_insn *rf1,*rf2;
4003 
4004       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
4005 
4006       jitc_get_stacki(0);
4007       jit_movr_p(JIT_R2,JIT_R0);
4008 
4009       jitc_svecpr();
4010       rf1 = jit_beqi_p(jit_forward(),JIT_R0,1);
4011       jit_prepare(2);
4012       jit_pusharg_p(JIT_R2);
4013       jit_movi_l(JIT_R0,as_oint(S(svref)));
4014       jit_pusharg_p(JIT_R0);
4015       jit_finish(error_no_svector);
4016       jit_patch(rf1);
4017       jitc_skip_stacki(1);
4018       jit_movr_p(JIT_V2,JIT_R2);
4019 
4020       jitc_get_valuesr_1();
4021       jit_movr_p(JIT_R2,JIT_R0);
4022 
4023       jitc_posfixnumpr();
4024       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
4025       jitc_posfixnum2valr();
4026       jit_movr_p(JIT_R2,JIT_V2);
4027       jit_movr_p(JIT_V2,JIT_R0);
4028       jitc_getlen_svecr();
4029       rf2 = jit_bltr_p(jit_forward(),JIT_V2,JIT_R0);
4030       jit_patch(rf1);
4031       /* ERROR */
4032       jit_movr_p(JIT_V2,JIT_R2);
4033       jitc_push_stackr();
4034       jitc_get_valuesr_1();
4035       jit_movr_p(JIT_R2,JIT_R0);
4036       jitc_push_stackr();
4037       jitc_push_stackr();
4038       jitc_push_stacki(as_oint(S(integer)));
4039       jitc_push_stacki(as_oint(Fixnum_0));
4040       jit_movr_p(JIT_R2,JIT_V2);
4041       jitc_getlen_svecr();
4042       jit_movr_p(JIT_R2,JIT_R0);
4043       jitc_ul2ix();
4044       jit_movr_p(JIT_R2,JIT_R0);
4045       jitc_push_stackr();
4046       jit_prepare(1);
4047       jit_movi_l(JIT_R0,1);
4048       jit_pusharg_p(JIT_R0);
4049       jit_finish(listof);
4050       jit_retval(JIT_R2);
4051       jitc_push_stackr();
4052       jit_prepare(1);
4053       jit_movi_l(JIT_R0,3);
4054       jit_pusharg_p(JIT_R0);
4055       jit_finish(listof);
4056       jit_retval(JIT_R2);
4057       jitc_push_stackr();
4058       jitc_get_stacki(3);
4059       jit_movr_p(JIT_R2,JIT_R0);
4060       jitc_push_stackr();
4061       jitc_push_stackr();
4062       jitc_push_stacki(as_oint(S(svref)));
4063       jitc_errori(type_error,"~S: ~S is not a correct index into ~S");
4064       jit_patch(rf2);
4065       jit_movr_p(JIT_R1,JIT_V2);
4066       jitc_get_svecdatax();
4067       jit_movr_p(JIT_R2,JIT_R0);
4068       jitc_set_valuesr_1();
4069 
4070       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
4071 
4072       goto next_byte;
4073     }
4074     CASE cod_svset: {           /* (SVSET) */
4075       jit_insn *rf1,*rf2;
4076 
4077       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
4078 
4079       jitc_get_stacki(0);
4080       jit_movr_p(JIT_R2,JIT_R0);
4081 
4082       jitc_svecpr();
4083       rf1 = jit_beqi_p(jit_forward(),JIT_R0,1);
4084       jit_prepare(2);
4085       jit_pusharg_p(JIT_R2);
4086       jit_movi_l(JIT_R0,as_oint(S(svref)));
4087       jit_pusharg_p(JIT_R0);
4088       jit_finish(error_no_svector);
4089       jit_patch(rf1);
4090       jitc_skip_stacki(1);
4091       jit_movr_p(JIT_V2,JIT_R2);
4092 
4093       jitc_get_valuesr_1();
4094       jit_movr_p(JIT_R2,JIT_R0);
4095 
4096       jitc_posfixnumpr();
4097       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
4098       jitc_posfixnum2valr();
4099       jit_movr_p(JIT_R2,JIT_V2);
4100       jit_movr_p(JIT_V2,JIT_R0);
4101       jitc_getlen_svecr();
4102       rf2 = jit_bltr_p(jit_forward(),JIT_V2,JIT_R0);
4103       jit_patch(rf1);
4104       /* ERROR */
4105       jit_movr_p(JIT_V2,JIT_R2);
4106       jitc_push_stackr();
4107       jitc_get_valuesr_1();
4108       jit_movr_p(JIT_R2,JIT_R0);
4109       jitc_push_stackr();
4110       jitc_push_stackr();
4111       jitc_push_stacki(as_oint(S(integer)));
4112       jitc_push_stacki(as_oint(Fixnum_0));
4113       jit_movr_p(JIT_R2,JIT_V2);
4114       jitc_getlen_svecr();
4115       jit_movr_p(JIT_R2,JIT_R0);
4116       jitc_ul2ix();
4117       jit_movr_p(JIT_R2,JIT_R0);
4118       jitc_push_stackr();
4119       jit_prepare(1);
4120       jit_movi_l(JIT_R0,1);
4121       jit_pusharg_p(JIT_R0);
4122       jit_finish(listof);
4123       jit_retval(JIT_R2);
4124       jitc_push_stackr();
4125       jit_prepare(1);
4126       jit_movi_l(JIT_R0,3);
4127       jit_pusharg_p(JIT_R0);
4128       jit_finish(listof);
4129       jit_retval(JIT_R2);
4130       jitc_push_stackr();
4131       jitc_get_stacki(3);
4132       jit_movr_p(JIT_R2,JIT_R0);
4133       jitc_push_stackr();
4134       jitc_push_stackr();
4135       jitc_push_stacki(as_oint(S(svref)));
4136       jitc_errori(type_error,"~S: ~S is not a correct index into ~S");
4137       jit_patch(rf2);
4138       jit_movr_p(JIT_R1,JIT_V2);
4139       jitc_getptr_svecdatax();
4140       jit_movr_p(JIT_R2,JIT_R0);
4141       jitc_pop_stack();
4142       jit_str_p(JIT_R2,JIT_R0);
4143       jit_movr_p(JIT_R2,JIT_R0);
4144       jitc_set_valuesr_1();
4145 
4146       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
4147 
4148       goto next_byte;
4149     }
4150     CASE cod_list: {            /* (LIST n) */
4151       uintC n;
4152       U_operand(n);
4153 
4154       jit_prepare(1);
4155       jit_movi_l(JIT_R0,n);
4156       jit_pusharg_p(JIT_R0);
4157       jit_finish(listof);
4158       jit_retval(JIT_R2);
4159       jitc_set_valuesr_1();
4160 
4161       jitc_tag_unsafe();
4162 
4163       goto next_byte;
4164     }
4165     CASE cod_list_push: {       /* (LIST&PUSH n) */
4166       uintC n;
4167       U_operand(n);
4168 
4169       jit_prepare(1);
4170       jit_movi_l(JIT_R0,n);
4171       jit_pusharg_p(JIT_R0);
4172       jit_finish(listof);
4173       jit_retval(JIT_R2);
4174       jitc_push_stackr();
4175 
4176       jitc_tag_unsafe();
4177       goto next_byte;
4178     }
4179     CASE cod_liststar: {        /* (LIST* n) */
4180       jit_insn* ref;
4181       uintC n;
4182       U_operand(n);
4183 
4184       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
4185       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
4186 
4187       jitc_get_valuesr_1();
4188       jit_movr_p(JIT_R2,JIT_R0);
4189       jitc_push_stackr();
4190 
4191       jit_movi_l(JIT_V2,n);
4192       ref = jit_get_label();
4193       (void)jit_calli(allocate_cons);
4194       jit_retval(JIT_V1);
4195       jit_movr_p(JIT_R2,JIT_V1);
4196       jitc_getptr_fieldr(Cons,cdr);
4197       jit_movr_p(JIT_R2,JIT_R0);
4198       jitc_pop_stack();
4199       jit_str_p(JIT_R2,JIT_R0);
4200       jit_movr_p(JIT_R2,JIT_V1);
4201       jitc_getptr_fieldr(Cons,car);
4202       jit_movr_p(JIT_R2,JIT_R0);
4203       jitc_get_stacki(0);
4204       jit_str_p(JIT_R2,JIT_R0);
4205 
4206       jitc_getptr_stacki(0);
4207       jit_str_p(JIT_R0,JIT_V1);
4208 
4209       jit_subi_p(JIT_V2,JIT_V2,1);
4210       jit_bnei_p(ref,JIT_V2,0);
4211 
4212       jitc_pop_stack();
4213       jit_movr_p(JIT_R2,JIT_R0);
4214       jitc_set_valuesr_1();
4215 
4216       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
4217       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
4218 
4219       jitc_tag_unsafe();
4220       goto next_byte;
4221     }
4222     CASE cod_liststar_push: {   /* (LIST*&PUSH n) */
4223       jit_insn *ref;
4224       uintC n;
4225       U_operand(n);
4226 
4227       jit_stxi_p(jitc_var_a,JIT_FP,JIT_V2);
4228       jit_stxi_p(jitc_var_b,JIT_FP,JIT_V1);
4229 
4230       jitc_get_valuesr_1();
4231       jit_movr_p(JIT_R2,JIT_R0);
4232       jitc_push_stackr();
4233 
4234       jit_movi_l(JIT_V2,n);
4235       ref = jit_get_label();
4236       (void)jit_calli(allocate_cons);
4237       jit_retval(JIT_V1);
4238       jit_movr_p(JIT_R2,JIT_V1);
4239       jitc_getptr_fieldr(Cons,cdr);
4240       jit_movr_p(JIT_R2,JIT_R0);
4241       jitc_pop_stack();
4242       jit_str_p(JIT_R2,JIT_R0);
4243       jit_movr_p(JIT_R2,JIT_V1);
4244       jitc_getptr_fieldr(Cons,car);
4245       jit_movr_p(JIT_R2,JIT_R0);
4246       jitc_get_stacki(0);
4247       jit_str_p(JIT_R2,JIT_R0);
4248 
4249       jitc_getptr_stacki(0);
4250       jit_str_p(JIT_R0,JIT_V1);
4251 
4252       jit_subi_p(JIT_V2,JIT_V2,1);
4253       jit_bnei_p(ref,JIT_V2,0);
4254 
4255       jit_ldxi_p(JIT_V1,JIT_FP,jitc_var_b);
4256       jit_ldxi_p(JIT_V2,JIT_FP,jitc_var_a);
4257 
4258       jitc_tag_unsafe();
4259       goto next_byte;
4260     }
4261     /* ------------------- (16) combined Operations ----------------------- */
4262     CASE cod_nil_store: {       /* (NIL&STORE n) */
4263       uintL n;
4264       U_operand(n);
4265 
4266       jit_movi_l(JIT_R2,as_oint(NIL));
4267 
4268       jitc_getptr_stacki(n);
4269       jit_str_p(JIT_R0,JIT_R2);
4270       jitc_set_valuesr_1();
4271 
4272       goto next_byte;
4273     }
4274     CASE cod_t_store: {         /* (T&STORE n) */
4275       uintL n;
4276       U_operand(n);
4277 
4278       jit_movi_l(JIT_R2,as_oint(T));
4279 
4280       jitc_getptr_stacki(n);
4281       jit_str_p(JIT_R0,JIT_R2);
4282       jitc_set_valuesr_1();
4283 
4284       goto next_byte;
4285     }
4286     CASE cod_calls1_store: {    /* (CALLS1&STORE n k) */
4287       uintL n;
4288       uintL k;
4289       B_operand(n);
4290       U_operand(k);
4291 
4292       jitc_funcalls1();
4293 
4294       jitc_get_valuesr_1();
4295       jit_movr_p(JIT_R2,JIT_R0);
4296       jitc_getptr_stacki(k);
4297       jit_str_p(JIT_R0, JIT_R2);
4298       jitc_set_valuesr_1();
4299 
4300       jitc_tag_unsafe();
4301       goto next_byte;
4302     }
4303     CASE cod_calls2_store: {    /* (CALLS2&STORE n k) */
4304       uintL n;
4305       uintL k;
4306       B_operand(n);
4307       U_operand(k);
4308 
4309       jitc_funcalls2();
4310 
4311       jitc_get_valuesr_1();
4312       jit_movr_p(JIT_R2,JIT_R0);
4313       jitc_getptr_stacki(k);
4314       jit_str_p(JIT_R0, JIT_R2);
4315       jitc_set_valuesr_1();
4316 
4317       jitc_tag_unsafe();
4318       goto next_byte;
4319     }
4320     CASE cod_callsr_store: {    /* (CALLSR&STORE m n k) */
4321       uintL m;
4322       uintL n;
4323       uintL k;
4324       U_operand(m);
4325       B_operand(n);
4326       U_operand(k);
4327 
4328       jitc_funcallsr();
4329 
4330       jitc_get_valuesr_1();
4331       jit_movr_p(JIT_R2,JIT_R0);
4332       jitc_getptr_stacki(k);
4333       jit_str_p(JIT_R0, JIT_R2);
4334       jitc_set_valuesr_1();
4335 
4336       jitc_tag_unsafe();
4337       goto next_byte;
4338     }
4339     CASE cod_load_inc_push: {   /* (LOAD&INC&PUSH n) */
4340       jit_insn *rf1,*rf2,*rf3;
4341       uintL n;
4342       U_operand(n);
4343 
4344       jitc_get_stacki(n);
4345       jit_movr_p(JIT_R2,JIT_R0);
4346 
4347       jitc_posfixnumpr();
4348       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
4349       rf2 = jit_beqi_p(jit_forward(), JIT_R2,as_oint(fixnum(vbitm(oint_data_len)-1)));
4350       jitc_inc_posfixnumir(1);
4351       rf3 = jit_jmpi(jit_forward());
4352       jit_patch(rf1);
4353       jit_patch(rf2);
4354       jitc_push_stackr();
4355       jitc_save_backtrace1(as_oint(L(plus_one)), STACK, -1,{
4356           (void)jit_calli(C_plus_one);
4357         });
4358       jitc_get_valuesr_1();
4359       jit_patch(rf3);
4360       jit_movr_p(JIT_R2,JIT_R0);
4361       jitc_push_stackr();
4362 
4363       jitc_tag_unsafe();
4364       goto next_byte;
4365     }
4366     CASE cod_load_inc_store: {  /* (LOAD&INC&STORE n) */
4367       jit_insn *rf1,*rf2,*rf3;
4368       uintL n;
4369       U_operand(n);
4370 
4371       jitc_get_stacki(n);
4372       jit_movr_p(JIT_R2,JIT_R0);
4373 
4374       jitc_posfixnumpr();
4375       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
4376       rf2 = jit_beqi_p(jit_forward(), JIT_R2,as_oint(fixnum(vbitm(oint_data_len)-1)));
4377       jitc_inc_posfixnumir(1);
4378       rf3 = jit_jmpi(jit_forward());
4379       jit_patch(rf1);
4380       jit_patch(rf2);
4381       jitc_push_stackr();
4382       jitc_save_backtrace1(as_oint(L(plus_one)), STACK, -1, {
4383           (void)jit_calli(C_plus_one);
4384         });
4385       jitc_get_valuesr_1();
4386       jit_patch(rf3);
4387       jit_movr_p(JIT_R2,JIT_R0);
4388       jitc_getptr_stacki(n);
4389       jit_str_p(JIT_R0,JIT_R2);
4390       jitc_set_valuesr_1();
4391 
4392       jitc_tag_unsafe();
4393       goto next_byte;
4394     }
4395     CASE cod_load_dec_push: {   /* (LOAD&DEC&PUSH n) */
4396       jit_insn *rf1,*rf2,*rf3;
4397       uintL n;
4398       U_operand(n);
4399 
4400       jitc_get_stacki(n);
4401       jit_movr_p(JIT_R2,JIT_R0);
4402 
4403       jitc_posfixnumpr();
4404       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
4405       rf2 = jit_beqi_p(jit_forward(), JIT_R2,as_oint(Fixnum_0));
4406       jitc_inc_posfixnumir(-1);
4407       rf3 = jit_jmpi(jit_forward());
4408       jit_patch(rf1);
4409       jit_patch(rf2);
4410       jitc_push_stackr();
4411       jitc_save_backtrace1(as_oint(L(minus_one)), STACK, -1, {
4412           (void)jit_calli(C_minus_one);
4413         });
4414       jitc_get_valuesr_1();
4415       jit_patch(rf3);
4416       jit_movr_p(JIT_R2,JIT_R0);
4417       jitc_push_stackr();
4418 
4419       jitc_tag_unsafe();
4420       goto next_byte;
4421     }
4422     CASE cod_load_dec_store: {  /* (LOAD&DEC&STORE n) */
4423       jit_insn *rf1,*rf2,*rf3;
4424       uintL n;
4425       U_operand(n);
4426 
4427       jitc_get_stacki(n);
4428       jit_movr_p(JIT_R2,JIT_R0);
4429 
4430       jitc_posfixnumpr();
4431       rf1 = jit_bnei_p(jit_forward(),JIT_R0,1);
4432       rf2 = jit_beqi_p(jit_forward(), JIT_R2,as_oint(Fixnum_0));
4433       jitc_inc_posfixnumir(-1);
4434       rf3 = jit_jmpi(jit_forward());
4435       jit_patch(rf1);
4436       jit_patch(rf2);
4437       jitc_push_stackr();
4438       jitc_save_backtrace1(as_oint(L(minus_one)), STACK, -1, {
4439           (void)jit_calli(C_minus_one);
4440         });
4441       jitc_get_valuesr_1();
4442       jit_patch(rf3);
4443       jit_movr_p(JIT_R2,JIT_R0);
4444       jitc_getptr_stacki(n);
4445       jit_str_p(JIT_R0,JIT_R2);
4446       jitc_set_valuesr_1();
4447 
4448       jitc_tag_unsafe();
4449       goto next_byte;
4450     }
4451     CASE cod_call1_jmpif: {     /* (CALL1&JMPIF n label) */
4452       const uintB* label_byteptr;
4453       jit_insn *rf1;
4454       uintL n;
4455       U_operand(n);
4456       L_operand(label_byteptr);
4457 
4458       jitc_funcall1();
4459       jitc_get_valuesr_1();
4460       rf1 = jit_beqi_p(jit_forward(),JIT_R0,as_oint(NIL));
4461       jitc_bcjmpi(label_byteptr - CODEPTR);
4462       jit_patch(rf1);
4463 
4464       jitc_tag_unsafe();
4465       goto next_byte;
4466     }
4467     CASE cod_call1_jmpifnot: {  /* (CALL1&JMPIFNOT n label) */
4468       const uintB* label_byteptr;
4469       jit_insn *rf1;
4470       uintL n;
4471       U_operand(n);
4472       L_operand(label_byteptr);
4473 
4474       jitc_funcall1();
4475       jitc_get_valuesr_1();
4476       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(NIL));
4477       jitc_bcjmpi(label_byteptr - CODEPTR);
4478       jit_patch(rf1);
4479 
4480       jitc_tag_unsafe();
4481       goto next_byte;
4482     }
4483     CASE cod_call2_jmpif: {     /* (CALL2&JMPIF n label) */
4484       const uintB* label_byteptr;
4485       jit_insn *rf1;
4486       uintL n;
4487       U_operand(n);
4488       L_operand(label_byteptr);
4489 
4490       jitc_funcall2();
4491       jitc_get_valuesr_1();
4492       rf1 = jit_beqi_p(jit_forward(),JIT_R0,as_oint(NIL));
4493       jitc_bcjmpi(label_byteptr - CODEPTR);
4494       jit_patch(rf1);
4495 
4496       jitc_tag_unsafe();
4497       goto next_byte;
4498     }
4499     CASE cod_call2_jmpifnot: {  /* (CALL2&JMPIFNOT n label) */
4500       const uintB* label_byteptr;
4501       jit_insn *rf1;
4502       uintL n;
4503       U_operand(n);
4504       L_operand(label_byteptr);
4505 
4506       jitc_funcall2();
4507       jitc_get_valuesr_1();
4508       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(NIL));
4509       jitc_bcjmpi(label_byteptr - CODEPTR);
4510       jit_patch(rf1);
4511 
4512       jitc_tag_unsafe();
4513       goto next_byte;
4514     }
4515     CASE cod_calls1_jmpif: {    /* (CALLS1&JMPIF n label) */
4516       const uintB* label_byteptr;
4517       jit_insn *rf1;
4518       uintL n;
4519       B_operand(n);
4520       L_operand(label_byteptr);
4521 
4522       jitc_funcalls1();
4523 
4524       jitc_get_valuesr_1();
4525       rf1 = jit_beqi_p(jit_forward(),JIT_R0,as_oint(NIL));
4526       jitc_bcjmpi(label_byteptr - CODEPTR);
4527       jit_patch(rf1);
4528 
4529       jitc_tag_unsafe();
4530       goto next_byte;
4531     }
4532     CASE cod_calls1_jmpifnot: { /* (CALLS1&JMPIFNOT n label) */
4533       const uintB* label_byteptr;
4534       jit_insn *rf1;
4535       uintL n;
4536       B_operand(n);
4537       L_operand(label_byteptr);
4538 
4539       jitc_funcalls1();
4540 
4541       jitc_get_valuesr_1();
4542       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(NIL));
4543       jitc_bcjmpi(label_byteptr - CODEPTR);
4544       jit_patch(rf1);
4545 
4546       jitc_tag_unsafe();
4547       goto next_byte;
4548     }
4549     CASE cod_calls2_jmpif: {    /* (CALLS2&JMPIF n label) */
4550       const uintB* label_byteptr;
4551       jit_insn *rf1;
4552       uintL n;
4553       B_operand(n);
4554       L_operand(label_byteptr);
4555 
4556       jitc_funcalls2();
4557 
4558       jitc_get_valuesr_1();
4559       rf1 = jit_beqi_p(jit_forward(),JIT_R0,as_oint(NIL));
4560       jitc_bcjmpi(label_byteptr - CODEPTR);
4561       jit_patch(rf1);
4562 
4563       jitc_tag_unsafe();
4564       goto next_byte;
4565     }
4566     CASE cod_calls2_jmpifnot: { /* (CALLS2&JMPIFNOT n label) */
4567       const uintB* label_byteptr;
4568       jit_insn *rf1;
4569       uintL n;
4570       B_operand(n);
4571       L_operand(label_byteptr);
4572 
4573       jitc_funcalls2();
4574 
4575       jitc_get_valuesr_1();
4576       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(NIL));
4577       jitc_bcjmpi(label_byteptr - CODEPTR);
4578       jit_patch(rf1);
4579 
4580       jitc_tag_unsafe();
4581       goto next_byte;
4582     }
4583     CASE cod_callsr_jmpif: {    /* (CALLSR&JMPIF m n label) */
4584       const uintB* label_byteptr;
4585       jit_insn *rf1;
4586       uintL m;
4587       uintL n;
4588       U_operand(m);
4589       B_operand(n);
4590       L_operand(label_byteptr);
4591 
4592       jitc_funcallsr();
4593 
4594       jitc_get_valuesr_1();
4595       rf1 = jit_beqi_p(jit_forward(),JIT_R0,as_oint(NIL));
4596       jitc_bcjmpi(label_byteptr - CODEPTR);
4597       jit_patch(rf1);
4598 
4599       jitc_tag_unsafe();
4600       goto next_byte;
4601     }
4602     CASE cod_callsr_jmpifnot: { /* (CALLSR&JMPIFNOT m n label) */
4603       const uintB* label_byteptr;
4604       jit_insn *rf1;
4605       uintL m;
4606       uintL n;
4607       U_operand(m);
4608       B_operand(n);
4609       L_operand(label_byteptr);
4610 
4611       jitc_funcallsr();
4612 
4613       jitc_get_valuesr_1();
4614       rf1 = jit_bnei_p(jit_forward(),JIT_R0,as_oint(NIL));
4615       jitc_bcjmpi(label_byteptr - CODEPTR);
4616       jit_patch(rf1);
4617 
4618       jitc_tag_unsafe();
4619       goto next_byte;
4620     }
4621     CASE cod_load_jmpif: {      /* (LOAD&JMPIF n label) */
4622       jit_insn *rf1;
4623       uintL n;
4624       const uintB* label_byteptr;
4625       U_operand(n);
4626       L_operand(label_byteptr);
4627 
4628       jitc_get_stacki(n);
4629       jit_movr_p(JIT_R2,JIT_R0);
4630       jitc_set_valuesr_1();
4631       rf1 = jit_beqi_p(jit_forward(),JIT_R2,as_oint(NIL));
4632       jitc_bcjmpi(label_byteptr - CODEPTR);
4633       jit_patch(rf1);
4634 
4635       goto next_byte;
4636     }
4637     CASE cod_load_jmpifnot: {   /* (LOAD&JMPIFNOT n label) */
4638       jit_insn *rf1;
4639       uintL n;
4640       const uintB* label_byteptr;
4641       U_operand(n);
4642       L_operand(label_byteptr);
4643 
4644       jitc_get_stacki(n);
4645       jit_movr_p(JIT_R2,JIT_R0);
4646       jitc_set_valuesr_1();
4647       rf1 = jit_bnei_p(jit_forward(),JIT_R2,as_oint(NIL));
4648       jitc_bcjmpi(label_byteptr - CODEPTR);
4649       jit_patch(rf1);
4650 
4651       goto next_byte;
4652     }
4653     CASE cod_apply_skip_ret: {  /* (APPLY&SKIP&RET n k) */
4654       uintL n;
4655       uintL k;
4656       U_operand(n);
4657       U_operand(k);
4658 
4659       jit_prepare(3);
4660       jitc_get_valuesr_1();
4661       jit_pusharg_p(JIT_R0);
4662       jit_movi_l(JIT_R0,n);
4663       jit_pusharg_p(JIT_R0);
4664       jitc_get_stacki(n);
4665       jit_pusharg_p(JIT_R0);
4666       jit_finish(apply);
4667       jitc_skip_stacki(k+1);
4668       jitc_return();
4669 
4670       jitc_tag_unsafe();
4671       goto next_byte;
4672     }
4673     CASE cod_funcall_skip_retgf: { /* (FUNCALL&SKIP&RETGF n k) */
4674       uintL n;
4675       uintL k;
4676       U_operand(n);
4677       U_operand(k);
4678       uintL r = ((Codevec)codeptr)->ccv_numreq;
4679       uintB flags = ((Codevec)codeptr)->ccv_flags;
4680 
4681       jit_prepare(2);
4682       jit_movi_l(JIT_R0,n);
4683       jit_pusharg_p(JIT_R0);
4684       jitc_get_stacki(n);
4685       jit_pusharg_p(JIT_R0);
4686       jit_finish(funcall);
4687       if (flags & bit(3)) { /* call inhibition? */
4688         jitc_skip_stacki(k+1);
4689         jitc_set_mvcounti(1);
4690       } else {
4691         k -= r;
4692         if (flags & bit(0)) {
4693           jitc_skip_stacki(k);
4694           jit_prepare(3);
4695           jitc_pop_stack();
4696           jit_pusharg_p(JIT_R0);
4697           jit_movi_l(JIT_R0,r);
4698           jit_pusharg_p(JIT_R0);
4699           jitc_get_valuesr_1();
4700           jit_pusharg_p(JIT_R0);
4701           jit_finish(apply);
4702         } else {
4703           jitc_skip_stacki(k+1);
4704           jit_prepare(2);
4705           jit_movi_l(JIT_R0,r);
4706           jit_pusharg_p(JIT_R0);
4707           jitc_get_valuesr_1();
4708           jit_pusharg_p(JIT_R0);
4709           jit_finish(funcall);
4710         }
4711       }
4712       jitc_return();
4713 
4714       jitc_tag_unsafe();
4715       goto next_byte;
4716     }
4717     /* ------------------- (17) short codes ----------------------- */
4718     CASE cod_load0: {           /* (LOAD.S 0) */
4719       jitc_get_stacki(0);
4720       jit_movr_p(JIT_R2,JIT_R0);
4721       jitc_set_valuesr_1();
4722 
4723       goto next_byte;
4724     }
4725     CASE cod_load1: {           /* (LOAD.S 1) */
4726       jitc_get_stacki(1);
4727       jit_movr_p(JIT_R2,JIT_R0);
4728       jitc_set_valuesr_1();
4729 
4730       goto next_byte;
4731     }
4732     CASE cod_load2: {           /* (LOAD.S 2) */
4733       jitc_get_stacki(2);
4734       jit_movr_p(JIT_R2,JIT_R0);
4735       jitc_set_valuesr_1();
4736 
4737       goto next_byte;
4738     }
4739     CASE cod_load3: {           /* (LOAD.S 3) */
4740       jitc_get_stacki(3);
4741       jit_movr_p(JIT_R2,JIT_R0);
4742       jitc_set_valuesr_1();
4743 
4744       goto next_byte;
4745     }
4746     CASE cod_load4: {           /* (LOAD.S 4) */
4747       jitc_get_stacki(4);
4748       jit_movr_p(JIT_R2,JIT_R0);
4749       jitc_set_valuesr_1();
4750 
4751       goto next_byte;
4752     }
4753     CASE cod_load5: {           /* (LOAD.S 5) */
4754       jitc_get_stacki(5);
4755       jit_movr_p(JIT_R2,JIT_R0);
4756       jitc_set_valuesr_1();
4757 
4758       goto next_byte;
4759     }
4760     CASE cod_load6: {           /* (LOAD.S 6) */
4761       jitc_get_stacki(6);
4762       jit_movr_p(JIT_R2,JIT_R0);
4763       jitc_set_valuesr_1();
4764 
4765       goto next_byte;
4766     }
4767     CASE cod_load7: {           /* (LOAD.S 7) */
4768       jitc_get_stacki(7);
4769       jit_movr_p(JIT_R2,JIT_R0);
4770       jitc_set_valuesr_1();
4771 
4772       goto next_byte;
4773     }
4774     CASE cod_load8: {           /* (LOAD.S 8) */
4775       jitc_get_stacki(8);
4776       jit_movr_p(JIT_R2,JIT_R0);
4777       jitc_set_valuesr_1();
4778 
4779       goto next_byte;
4780     }
4781     CASE cod_load9: {           /* (LOAD.S 9) */
4782       jitc_get_stacki(9);
4783       jit_movr_p(JIT_R2,JIT_R0);
4784       jitc_set_valuesr_1();
4785 
4786       goto next_byte;
4787     }
4788     CASE cod_load10: {          /* (LOAD.S 10) */
4789       jitc_get_stacki(10);
4790       jit_movr_p(JIT_R2,JIT_R0);
4791       jitc_set_valuesr_1();
4792 
4793       goto next_byte;
4794     }
4795     CASE cod_load11: {          /* (LOAD.S 11) */
4796       jitc_get_stacki(11);
4797       jit_movr_p(JIT_R2,JIT_R0);
4798       jitc_set_valuesr_1();
4799 
4800       goto next_byte;
4801     }
4802     CASE cod_load12: {          /* (LOAD.S 12) */
4803       jitc_get_stacki(12);
4804       jit_movr_p(JIT_R2,JIT_R0);
4805       jitc_set_valuesr_1();
4806 
4807       goto next_byte;
4808     }
4809     CASE cod_load13: {          /* (LOAD.S 13) */
4810       jitc_get_stacki(13);
4811       jit_movr_p(JIT_R2,JIT_R0);
4812       jitc_set_valuesr_1();
4813 
4814       goto next_byte;
4815     }
4816     CASE cod_load14: {          /* (LOAD.S 14) */
4817       jitc_get_stacki(14);
4818       jit_movr_p(JIT_R2,JIT_R0);
4819       jitc_set_valuesr_1();
4820 
4821       goto next_byte;
4822     }
4823     CASE cod_load_push0: {      /* (LOAD&PUSH.S 0) */
4824       jitc_get_stacki(0);
4825       jit_movr_p(JIT_R2,JIT_R0);
4826       jitc_push_stackr();
4827 
4828       goto next_byte;
4829     }
4830     CASE cod_load_push1: {      /* (LOAD&PUSH.S 1) */
4831       jitc_get_stacki(1);
4832       jit_movr_p(JIT_R2,JIT_R0);
4833       jitc_push_stackr();
4834 
4835       goto next_byte;
4836     }
4837     CASE cod_load_push2: {      /* (LOAD&PUSH.S 2) */
4838       jitc_get_stacki(2);
4839       jit_movr_p(JIT_R2,JIT_R0);
4840       jitc_push_stackr();
4841 
4842       goto next_byte;
4843     }
4844     CASE cod_load_push3: {      /* (LOAD&PUSH.S 3) */
4845       jitc_get_stacki(3);
4846       jit_movr_p(JIT_R2,JIT_R0);
4847       jitc_push_stackr();
4848 
4849       goto next_byte;
4850     }
4851     CASE cod_load_push4: {      /* (LOAD&PUSH.S 4) */
4852       jitc_get_stacki(4);
4853       jit_movr_p(JIT_R2,JIT_R0);
4854       jitc_push_stackr();
4855 
4856       goto next_byte;
4857     }
4858     CASE cod_load_push5: {      /* (LOAD&PUSH.S 5) */
4859       jitc_get_stacki(5);
4860       jit_movr_p(JIT_R2,JIT_R0);
4861       jitc_push_stackr();
4862 
4863       goto next_byte;
4864     }
4865     CASE cod_load_push6: {      /* (LOAD&PUSH.S 6) */
4866       jitc_get_stacki(6);
4867       jit_movr_p(JIT_R2,JIT_R0);
4868       jitc_push_stackr();
4869 
4870       goto next_byte;
4871     }
4872     CASE cod_load_push7: {      /* (LOAD&PUSH.S 7) */
4873       jitc_get_stacki(7);
4874       jit_movr_p(JIT_R2,JIT_R0);
4875       jitc_push_stackr();
4876 
4877       goto next_byte;
4878     }
4879     CASE cod_load_push8: {      /* (LOAD&PUSH.S 8) */
4880       jitc_get_stacki(8);
4881       jit_movr_p(JIT_R2,JIT_R0);
4882       jitc_push_stackr();
4883 
4884       goto next_byte;
4885     }
4886     CASE cod_load_push9: {      /* (LOAD&PUSH.S 9) */
4887       jitc_get_stacki(9);
4888       jit_movr_p(JIT_R2,JIT_R0);
4889       jitc_push_stackr();
4890 
4891       goto next_byte;
4892     }
4893     CASE cod_load_push10: {     /* (LOAD&PUSH.S 10) */
4894       jitc_get_stacki(10);
4895       jit_movr_p(JIT_R2,JIT_R0);
4896       jitc_push_stackr();
4897 
4898       goto next_byte;
4899     }
4900     CASE cod_load_push11: {     /* (LOAD&PUSH.S 11) */
4901       jitc_get_stacki(11);
4902       jit_movr_p(JIT_R2,JIT_R0);
4903       jitc_push_stackr();
4904 
4905       goto next_byte;
4906     }
4907     CASE cod_load_push12: {     /* (LOAD&PUSH.S 12) */
4908       jitc_get_stacki(12);
4909       jit_movr_p(JIT_R2,JIT_R0);
4910       jitc_push_stackr();
4911 
4912       goto next_byte;
4913     }
4914     CASE cod_load_push13: {     /* (LOAD&PUSH.S 13) */
4915       jitc_get_stacki(13);
4916       jit_movr_p(JIT_R2,JIT_R0);
4917       jitc_push_stackr();
4918 
4919       goto next_byte;
4920     }
4921     CASE cod_load_push14: {     /* (LOAD&PUSH.S 14) */
4922       jitc_get_stacki(14);
4923       jit_movr_p(JIT_R2,JIT_R0);
4924       jitc_push_stackr();
4925 
4926       goto next_byte;
4927     }
4928     CASE cod_load_push15: {     /* (LOAD&PUSH.S 15) */
4929       jitc_get_stacki(15);
4930       jit_movr_p(JIT_R2,JIT_R0);
4931       jitc_push_stackr();
4932 
4933       goto next_byte;
4934     }
4935     CASE cod_load_push16: {     /* (LOAD&PUSH.S 16) */
4936       jitc_get_stacki(16);
4937       jit_movr_p(JIT_R2,JIT_R0);
4938       jitc_push_stackr();
4939 
4940       goto next_byte;
4941     }
4942     CASE cod_load_push17: {     /* (LOAD&PUSH.S 17) */
4943       jitc_get_stacki(17);
4944       jit_movr_p(JIT_R2,JIT_R0);
4945       jitc_push_stackr();
4946 
4947       goto next_byte;
4948     }
4949     CASE cod_load_push18: {     /* (LOAD&PUSH.S 18) */
4950       jitc_get_stacki(18);
4951       jit_movr_p(JIT_R2,JIT_R0);
4952       jitc_push_stackr();
4953 
4954       goto next_byte;
4955     }
4956     CASE cod_load_push19: {     /* (LOAD&PUSH.S 19) */
4957       jitc_get_stacki(19);
4958       jit_movr_p(JIT_R2,JIT_R0);
4959       jitc_push_stackr();
4960 
4961       goto next_byte;
4962     }
4963     CASE cod_load_push20: {     /* (LOAD&PUSH.S 20) */
4964       jitc_get_stacki(20);
4965       jit_movr_p(JIT_R2,JIT_R0);
4966       jitc_push_stackr();
4967 
4968       goto next_byte;
4969     }
4970     CASE cod_load_push21: {     /* (LOAD&PUSH.S 21) */
4971       jitc_get_stacki(21);
4972       jit_movr_p(JIT_R2,JIT_R0);
4973       jitc_push_stackr();
4974 
4975       goto next_byte;
4976     }
4977     CASE cod_load_push22: {     /* (LOAD&PUSH.S 22) */
4978       jitc_get_stacki(22);
4979       jit_movr_p(JIT_R2,JIT_R0);
4980       jitc_push_stackr();
4981 
4982       goto next_byte;
4983     }
4984     CASE cod_load_push23: {     /* (LOAD&PUSH.S 23) */
4985       jitc_get_stacki(23);
4986       jit_movr_p(JIT_R2,JIT_R0);
4987       jitc_push_stackr();
4988 
4989       goto next_byte;
4990     }
4991     CASE cod_load_push24: {     /* (LOAD&PUSH.S 24) */
4992       jitc_get_stacki(24);
4993       jit_movr_p(JIT_R2,JIT_R0);
4994       jitc_push_stackr();
4995 
4996       goto next_byte;
4997     }
4998     CASE cod_const0: {          /* (CONST.S 0) */
4999       jitc_get_cconsti(0);
5000       jit_movr_p(JIT_R2,JIT_R0);
5001       jitc_set_valuesr_1();
5002 
5003       goto next_byte;
5004     }
5005     CASE cod_const1: {          /* (CONST.S 1) */
5006       jitc_get_cconsti(1);
5007       jit_movr_p(JIT_R2,JIT_R0);
5008       jitc_set_valuesr_1();
5009 
5010       goto next_byte;
5011     }
5012     CASE cod_const2: {          /* (CONST.S 2) */
5013       jitc_get_cconsti(2);
5014       jit_movr_p(JIT_R2,JIT_R0);
5015       jitc_set_valuesr_1();
5016 
5017       goto next_byte;
5018     }
5019     CASE cod_const3: {          /* (CONST.S 3) */
5020       jitc_get_cconsti(3);
5021       jit_movr_p(JIT_R2,JIT_R0);
5022       jitc_set_valuesr_1();
5023 
5024       goto next_byte;
5025     }
5026     CASE cod_const4: {          /* (CONST.S 4) */
5027       jitc_get_cconsti(4);
5028       jit_movr_p(JIT_R2,JIT_R0);
5029       jitc_set_valuesr_1();
5030 
5031       goto next_byte;
5032     }
5033     CASE cod_const5: {          /* (CONST.S 5) */
5034       jitc_get_cconsti(5);
5035       jit_movr_p(JIT_R2,JIT_R0);
5036       jitc_set_valuesr_1();
5037 
5038       goto next_byte;
5039     }
5040     CASE cod_const6: {          /* (CONST.S 6) */
5041       jitc_get_cconsti(6);
5042       jit_movr_p(JIT_R2,JIT_R0);
5043       jitc_set_valuesr_1();
5044 
5045       goto next_byte;
5046     }
5047     CASE cod_const7: {          /* (CONST.S 7) */
5048       jitc_get_cconsti(7);
5049       jit_movr_p(JIT_R2,JIT_R0);
5050       jitc_set_valuesr_1();
5051 
5052       goto next_byte;
5053     }
5054     CASE cod_const8: {          /* (CONST.S 8) */
5055       jitc_get_cconsti(8);
5056       jit_movr_p(JIT_R2,JIT_R0);
5057       jitc_set_valuesr_1();
5058 
5059       goto next_byte;
5060     }
5061     CASE cod_const9: {          /* (CONST.S 9) */
5062       jitc_get_cconsti(9);
5063       jit_movr_p(JIT_R2,JIT_R0);
5064       jitc_set_valuesr_1();
5065 
5066       goto next_byte;
5067     }
5068     CASE cod_const10: {         /* (CONST.S 10) */
5069       jitc_get_cconsti(10);
5070       jit_movr_p(JIT_R2,JIT_R0);
5071       jitc_set_valuesr_1();
5072 
5073       goto next_byte;
5074     }
5075     CASE cod_const11: {         /* (CONST.S 11) */
5076       jitc_get_cconsti(11);
5077       jit_movr_p(JIT_R2,JIT_R0);
5078       jitc_set_valuesr_1();
5079 
5080       goto next_byte;
5081     }
5082     CASE cod_const12: {         /* (CONST.S 12) */
5083       jitc_get_cconsti(12);
5084       jit_movr_p(JIT_R2,JIT_R0);
5085       jitc_set_valuesr_1();
5086 
5087       goto next_byte;
5088     }
5089     CASE cod_const13: {         /* (CONST.S 13) */
5090       jitc_get_cconsti(13);
5091       jit_movr_p(JIT_R2,JIT_R0);
5092       jitc_set_valuesr_1();
5093 
5094       goto next_byte;
5095     }
5096     CASE cod_const14: {         /* (CONST.S 14) */
5097       jitc_get_cconsti(14);
5098       jit_movr_p(JIT_R2,JIT_R0);
5099       jitc_set_valuesr_1();
5100 
5101       goto next_byte;
5102     }
5103     CASE cod_const15: {         /* (CONST.S 15) */
5104       jitc_get_cconsti(15);
5105       jit_movr_p(JIT_R2,JIT_R0);
5106       jitc_set_valuesr_1();
5107 
5108       goto next_byte;
5109     }
5110     CASE cod_const16: {         /* (CONST.S 16) */
5111       jitc_get_cconsti(16);
5112       jit_movr_p(JIT_R2,JIT_R0);
5113       jitc_set_valuesr_1();
5114 
5115       goto next_byte;
5116     }
5117     CASE cod_const17: {         /* (CONST.S 17) */
5118       jitc_get_cconsti(17);
5119       jit_movr_p(JIT_R2,JIT_R0);
5120       jitc_set_valuesr_1();
5121 
5122       goto next_byte;
5123     }
5124     CASE cod_const18: {         /* (CONST.S 18) */
5125       jitc_get_cconsti(18);
5126       jit_movr_p(JIT_R2,JIT_R0);
5127       jitc_set_valuesr_1();
5128 
5129       goto next_byte;
5130     }
5131     CASE cod_const19: {         /* (CONST.S 19) */
5132       jitc_get_cconsti(19);
5133       jit_movr_p(JIT_R2,JIT_R0);
5134       jitc_set_valuesr_1();
5135 
5136       goto next_byte;
5137     }
5138     CASE cod_const20: {         /* (CONST.S 20) */
5139       jitc_get_cconsti(20);
5140       jit_movr_p(JIT_R2,JIT_R0);
5141       jitc_set_valuesr_1();
5142 
5143       goto next_byte;
5144     }
5145     CASE cod_const_push0: {     /* (CONST&PUSH.S 0) */
5146       jitc_get_cconsti(0);
5147       jit_movr_p(JIT_R2,JIT_R0);
5148       jitc_push_stackr();
5149 
5150       goto next_byte;
5151     }
5152     CASE cod_const_push1: {     /* (CONST&PUSH.S 1) */
5153       jitc_get_cconsti(1);
5154       jit_movr_p(JIT_R2,JIT_R0);
5155       jitc_push_stackr();
5156 
5157       goto next_byte;
5158     }
5159     CASE cod_const_push2: {     /* (CONST&PUSH.S 2) */
5160       jitc_get_cconsti(2);
5161       jit_movr_p(JIT_R2,JIT_R0);
5162       jitc_push_stackr();
5163 
5164       goto next_byte;
5165     }
5166     CASE cod_const_push3: {     /* (CONST&PUSH.S 3) */
5167       jitc_get_cconsti(3);
5168       jit_movr_p(JIT_R2,JIT_R0);
5169       jitc_push_stackr();
5170 
5171       goto next_byte;
5172     }
5173     CASE cod_const_push4: {     /* (CONST&PUSH.S 4) */
5174       jitc_get_cconsti(4);
5175       jit_movr_p(JIT_R2,JIT_R0);
5176       jitc_push_stackr();
5177 
5178       goto next_byte;
5179     }
5180     CASE cod_const_push5: {     /* (CONST&PUSH.S 5) */
5181       jitc_get_cconsti(5);
5182       jit_movr_p(JIT_R2,JIT_R0);
5183       jitc_push_stackr();
5184 
5185       goto next_byte;
5186     }
5187     CASE cod_const_push6: {     /* (CONST&PUSH.S 6) */
5188       jitc_get_cconsti(6);
5189       jit_movr_p(JIT_R2,JIT_R0);
5190       jitc_push_stackr();
5191 
5192       goto next_byte;
5193     }
5194     CASE cod_const_push7: {     /* (CONST&PUSH.S 7) */
5195       jitc_get_cconsti(7);
5196       jit_movr_p(JIT_R2,JIT_R0);
5197       jitc_push_stackr();
5198 
5199       goto next_byte;
5200     }
5201     CASE cod_const_push8: {     /* (CONST&PUSH.S 8) */
5202       jitc_get_cconsti(8);
5203       jit_movr_p(JIT_R2,JIT_R0);
5204       jitc_push_stackr();
5205 
5206       goto next_byte;
5207     }
5208     CASE cod_const_push9: {     /* (CONST&PUSH.S 9) */
5209       jitc_get_cconsti(9);
5210       jit_movr_p(JIT_R2,JIT_R0);
5211       jitc_push_stackr();
5212 
5213       goto next_byte;
5214     }
5215     CASE cod_const_push10: {    /* (CONST&PUSH.S 10) */
5216       jitc_get_cconsti(10);
5217       jit_movr_p(JIT_R2,JIT_R0);
5218       jitc_push_stackr();
5219 
5220       goto next_byte;
5221     }
5222     CASE cod_const_push11: {    /* (CONST&PUSH.S 11) */
5223       jitc_get_cconsti(11);
5224       jit_movr_p(JIT_R2,JIT_R0);
5225       jitc_push_stackr();
5226 
5227       goto next_byte;
5228     }
5229     CASE cod_const_push12: {    /* (CONST&PUSH.S 12) */
5230       jitc_get_cconsti(12);
5231       jit_movr_p(JIT_R2,JIT_R0);
5232       jitc_push_stackr();
5233 
5234       goto next_byte;
5235     }
5236     CASE cod_const_push13: {    /* (CONST&PUSH.S 13) */
5237       jitc_get_cconsti(13);
5238       jit_movr_p(JIT_R2,JIT_R0);
5239       jitc_push_stackr();
5240 
5241       goto next_byte;
5242     }
5243     CASE cod_const_push14: {    /* (CONST&PUSH.S 14) */
5244       jitc_get_cconsti(14);
5245       jit_movr_p(JIT_R2,JIT_R0);
5246       jitc_push_stackr();
5247 
5248       goto next_byte;
5249     }
5250     CASE cod_const_push15: {    /* (CONST&PUSH.S 15) */
5251       jitc_get_cconsti(15);
5252       jit_movr_p(JIT_R2,JIT_R0);
5253       jitc_push_stackr();
5254 
5255       goto next_byte;
5256     }
5257     CASE cod_const_push16: {    /* (CONST&PUSH.S 16) */
5258       jitc_get_cconsti(16);
5259       jit_movr_p(JIT_R2,JIT_R0);
5260       jitc_push_stackr();
5261 
5262       goto next_byte;
5263     }
5264     CASE cod_const_push17: {    /* (CONST&PUSH.S 17) */
5265       jitc_get_cconsti(17);
5266       jit_movr_p(JIT_R2,JIT_R0);
5267       jitc_push_stackr();
5268 
5269       goto next_byte;
5270     }
5271     CASE cod_const_push18: {    /* (CONST&PUSH.S 18) */
5272       jitc_get_cconsti(18);
5273       jit_movr_p(JIT_R2,JIT_R0);
5274       jitc_push_stackr();
5275 
5276       goto next_byte;
5277     }
5278     CASE cod_const_push19: {    /* (CONST&PUSH.S 19) */
5279       jitc_get_cconsti(19);
5280       jit_movr_p(JIT_R2,JIT_R0);
5281       jitc_push_stackr();
5282 
5283       goto next_byte;
5284     }
5285     CASE cod_const_push20: {    /* (CONST&PUSH.S 20) */
5286       jitc_get_cconsti(20);
5287       jit_movr_p(JIT_R2,JIT_R0);
5288       jitc_push_stackr();
5289 
5290       goto next_byte;
5291     }
5292     CASE cod_const_push21: {    /* (CONST&PUSH.S 21) */
5293       jitc_get_cconsti(21);
5294       jit_movr_p(JIT_R2,JIT_R0);
5295       jitc_push_stackr();
5296 
5297       goto next_byte;
5298     }
5299     CASE cod_const_push22: {    /* (CONST&PUSH.S 22) */
5300       jitc_get_cconsti(22);
5301       jit_movr_p(JIT_R2,JIT_R0);
5302       jitc_push_stackr();
5303 
5304       goto next_byte;
5305     }
5306     CASE cod_const_push23: {    /* (CONST&PUSH.S 23) */
5307       jitc_get_cconsti(23);
5308       jit_movr_p(JIT_R2,JIT_R0);
5309       jitc_push_stackr();
5310 
5311       goto next_byte;
5312     }
5313     CASE cod_const_push24: {    /* (CONST&PUSH.S 24) */
5314       jitc_get_cconsti(24);
5315       jit_movr_p(JIT_R2,JIT_R0);
5316       jitc_push_stackr();
5317 
5318       goto next_byte;
5319     }
5320     CASE cod_const_push25: {    /* (CONST&PUSH.S 25) */
5321       jitc_get_cconsti(25);
5322       jit_movr_p(JIT_R2,JIT_R0);
5323       jitc_push_stackr();
5324 
5325       goto next_byte;
5326     }
5327     CASE cod_const_push26: {    /* (CONST&PUSH.S 26) */
5328       jitc_get_cconsti(26);
5329       jit_movr_p(JIT_R2,JIT_R0);
5330       jitc_push_stackr();
5331 
5332       goto next_byte;
5333     }
5334     CASE cod_const_push27: {    /* (CONST&PUSH.S 27) */
5335       jitc_get_cconsti(27);
5336       jit_movr_p(JIT_R2,JIT_R0);
5337       jitc_push_stackr();
5338 
5339       goto next_byte;
5340     }
5341     CASE cod_const_push28: {    /* (CONST&PUSH.S 28) */
5342       jitc_get_cconsti(28);
5343       jit_movr_p(JIT_R2,JIT_R0);
5344       jitc_push_stackr();
5345 
5346       goto next_byte;
5347     }
5348     CASE cod_const_push29: {    /* (CONST&PUSH.S 29) */
5349       jitc_get_cconsti(29);
5350       jit_movr_p(JIT_R2,JIT_R0);
5351       jitc_push_stackr();
5352 
5353       goto next_byte;
5354     }
5355     CASE cod_store0: {          /* (STORE.S 0) */
5356       jitc_get_valuesr_1();
5357       jit_movr_p(JIT_R2,JIT_R0);
5358       jitc_getptr_stacki(0);
5359       jit_str_p(JIT_R0,JIT_R2);
5360       jitc_set_mvcounti(1);
5361 
5362       goto next_byte;
5363     }
5364     CASE cod_store1: {          /* (STORE.S 1) */
5365       jitc_get_valuesr_1();
5366       jit_movr_p(JIT_R2,JIT_R0);
5367       jitc_getptr_stacki(1);
5368       jit_str_p(JIT_R0,JIT_R2);
5369       jitc_set_mvcounti(1);
5370 
5371       goto next_byte;
5372     }
5373     CASE cod_store2: {          /* (STORE.S 2) */
5374       jitc_get_valuesr_1();
5375       jit_movr_p(JIT_R2,JIT_R0);
5376       jitc_getptr_stacki(2);
5377       jit_str_p(JIT_R0,JIT_R2);
5378       jitc_set_mvcounti(1);
5379 
5380       goto next_byte;
5381     }
5382     CASE cod_store3: {          /* (STORE.S 3) */
5383       jitc_get_valuesr_1();
5384       jit_movr_p(JIT_R2,JIT_R0);
5385       jitc_getptr_stacki(3);
5386       jit_str_p(JIT_R0,JIT_R2);
5387       jitc_set_mvcounti(1);
5388 
5389       goto next_byte;
5390     }
5391     CASE cod_store4: {          /* (STORE.S 4) */
5392       jitc_get_valuesr_1();
5393       jit_movr_p(JIT_R2,JIT_R0);
5394       jitc_getptr_stacki(4);
5395       jit_str_p(JIT_R0,JIT_R2);
5396       jitc_set_mvcounti(1);
5397 
5398       goto next_byte;
5399     }
5400     CASE cod_store5: {          /* (STORE.S 5) */
5401       jitc_get_valuesr_1();
5402       jit_movr_p(JIT_R2,JIT_R0);
5403       jitc_getptr_stacki(5);
5404       jit_str_p(JIT_R0,JIT_R2);
5405       jitc_set_mvcounti(1);
5406 
5407       goto next_byte;
5408     }
5409     CASE cod_store6: {          /* (STORE.S 6) */
5410       jitc_get_valuesr_1();
5411       jit_movr_p(JIT_R2,JIT_R0);
5412       jitc_getptr_stacki(6);
5413       jit_str_p(JIT_R0,JIT_R2);
5414       jitc_set_mvcounti(1);
5415 
5416       goto next_byte;
5417     }
5418     CASE cod_store7: {          /* (STORE.S 7) */
5419       jitc_get_valuesr_1();
5420       jit_movr_p(JIT_R2,JIT_R0);
5421       jitc_getptr_stacki(7);
5422       jit_str_p(JIT_R0,JIT_R2);
5423       jitc_set_mvcounti(1);
5424 
5425       goto next_byte;
5426     }
5427     /* ------------------- miscellaneous ----------------------- */
5428     default:
5429       /* undefined Code */
5430   #if defined(GNU) && defined(FAST_SP)
5431       /* Undo the effect of -fomit-frame-pointer for this function,
5432          hereby allowing utilization of %sp resp. %esp as private_SP: */
5433       alloca(1);
5434   #endif
5435       pushSTACK(fixnum(byteptr-&codeptr->data[0]-1)); /* bad byte number */
5436       pushSTACK(closure); /* Closure */
5437       error(serious_condition,GETTEXT("undefined bytecode in ~S at byte ~S"));
5438   #undef L_operand
5439   #undef S_operand
5440   #undef U_operand
5441   #undef B_operand
5442   #undef CASE
5443   }
5444 #if DEBUG_BYTECODE
5445  error_byteptr:
5446   pushSTACK(fixnum(byteptr_max));
5447   pushSTACK(fixnum(byteptr_min));
5448   pushSTACK(fixnum(byteptr - codeptr->data));
5449   pushSTACK(sfixnum(byteptr_bad_jump));
5450   pushSTACK(closure);
5451   error(error_condition,GETTEXT("~S: jump by ~S takes ~S outside [~S;~S]"));
5452 #endif
5453  error_toomany_values:
5454   pushSTACK(closure);
5455   error(error_condition,GETTEXT("~S: too many return values"));
5456 #if STACKCHECKC
5457  error_STACK_putt:
5458   pushSTACK(fixnum(byteptr - codeptr->data - byteptr_min)); /* PC */
5459   pushSTACK(closure);                       /* FUNC */
5460   error(serious_condition,GETTEXT("Corrupted STACK in ~S at byte ~S"));
5461 #endif
5462  finished:
5463   /* disassemble(stderr, codeBuffer, jit_get_ip().ptr); */
5464   jit_flush_code(codeBuffer, jit_get_ip().ptr);
5465   return;
5466 }
5467 
5468 /* ensure that the function has been jit-compiled and run it */
jitc_run(object closure_in,Sbvector codeptr,const uintB * byteptr_in)5469 static Values jitc_run (object closure_in, Sbvector codeptr,
5470                         const uintB* byteptr_in) {
5471   struct jitc_object *jo;
5472   if (!fpointerp(cclosure_jitc(closure_in))) {
5473     pushSTACK(closure_in);
5474     { object fp = allocate_fpointer(NULL);
5475       closure_in = popSTACK();
5476       cclosure_jitc(closure_in) = fp; }
5477     jit_compile_(closure_in,codeptr,byteptr_in);
5478   }
5479   jo = TheFpointer(cclosure_jitc(closure_in))->fp_pointer;
5480   { jitc_func bc_func = (jitc_func) (jit_set_ip(jo->code_buffer).iptr);
5481     bc_func(closure, byteptr_in - CODEPTR); }
5482 }
5483