CACAO
emit.cpp
Go to the documentation of this file.
1 /* src/vm/jit/i386/emit.cpp - i386 code emitter functions
2 
3  Copyright (C) 1996-2014
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 
26 #include "config.h"
27 
28 #include <assert.h>
29 
30 #include "vm/types.hpp"
31 #include "vm/os.hpp"
32 
33 #include "vm/jit/i386/codegen.hpp"
34 #include "vm/jit/i386/emit.hpp"
35 #include "vm/jit/i386/md-abi.hpp"
36 
37 #include "mm/memory.hpp"
38 
39 #include "threads/lock.hpp"
40 
41 #include "vm/descriptor.hpp" // for typedesc, methoddesc, etc
42 #include "vm/options.hpp"
43 #include "vm/statistics.hpp"
44 
45 #include "vm/jit/abi.hpp"
46 #include "vm/jit/abi-asm.hpp"
47 #include "vm/jit/asmpart.hpp"
48 #include "vm/jit/builtin.hpp"
49 #include "vm/jit/code.hpp"
51 #include "vm/jit/dseg.hpp"
52 #include "vm/jit/emit-common.hpp"
53 #include "vm/jit/jit.hpp"
55 #include "vm/jit/replace.hpp"
56 #include "vm/jit/trace.hpp"
57 #include "vm/jit/trap.hpp"
58 
60 
61 
62 STAT_DECLARE_VAR(int,count_mov_reg_reg,0)
63 STAT_DECLARE_VAR(int,count_mov_mem_reg,0)
64 STAT_DECLARE_VAR(int,count_mov_reg_mem,0)
65 STAT_DECLARE_VAR(int,count_mov_mem_mem,0)
66 
67 /* emit_load ******************************************************************
68 
69  Emits a possible load of an operand.
70 
71 *******************************************************************************/
72 
73 s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
74 {
75  codegendata *cd;
76  s4 disp;
77  s4 reg;
78 
79  /* get required compiler data */
80 
81  cd = jd->cd;
82 
83  if (IS_INMEMORY(src->flags)) {
85 
86  disp = src->vv.regoff;
87 
88  switch (src->type) {
89  case TYPE_INT:
90  case TYPE_ADR:
91  M_ILD(tempreg, REG_SP, disp);
92  break;
93  case TYPE_LNG:
94  M_LLD(tempreg, REG_SP, disp);
95  break;
96  case TYPE_FLT:
97  M_FLD(tempreg, REG_SP, disp);
98  break;
99  case TYPE_DBL:
100  M_DLD(tempreg, REG_SP, disp);
101  break;
102  default:
103  vm_abort("emit_load: unknown type %d", src->type);
104  break;
105  }
106 
107  reg = tempreg;
108  }
109  else
110  reg = src->vv.regoff;
111 
112  return reg;
113 }
114 
115 
116 /* emit_load_low ************************************************************
117 
118  Emits a possible load of the low 32-bits of an operand.
119 
120 *******************************************************************************/
121 
122 s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src,s4 tempreg)
123 {
124  codegendata *cd;
125  s4 disp;
126  s4 reg;
127 
128  assert(src->type == TYPE_LNG);
129 
130  /* get required compiler data */
131 
132  cd = jd->cd;
133 
134 
135  if (IS_INMEMORY(src->flags)) {
136  COUNT_SPILLS;
137 
138  disp = src->vv.regoff;
139 
140  M_ILD(tempreg, REG_SP, disp);
141 
142  reg = tempreg;
143  }
144  else
145  reg = GET_LOW_REG(src->vv.regoff);
146 
147  return reg;
148 }
149 
150 
151 /* emit_load_high ***********************************************************
152 
153  Emits a possible load of the high 32-bits of an operand.
154 
155 *******************************************************************************/
156 
157 s4 emit_load_high(jitdata *jd, instruction *iptr,varinfo *src,s4 tempreg)
158 {
159  codegendata *cd;
160  s4 disp;
161  s4 reg;
162 
163  /* get required compiler data */
164 
165  assert(src->type == TYPE_LNG);
166 
167  cd = jd->cd;
168 
169  if (IS_INMEMORY(src->flags)) {
170  COUNT_SPILLS;
171 
172  disp = src->vv.regoff;
173 
174  M_ILD(tempreg, REG_SP, disp + 4);
175 
176  reg = tempreg;
177  }
178  else
179  reg = GET_HIGH_REG(src->vv.regoff);
180 
181  return reg;
182 }
183 
184 
185 /* emit_store ******************************************************************
186 
187  Emits a possible store of the destination operand.
188 
189 *******************************************************************************/
190 
191 void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
192 {
193  codegendata *cd;
194  s4 disp;
195 
196  /* get required compiler data */
197 
198  cd = jd->cd;
199 
200  if (IS_INMEMORY(dst->flags)) {
201  COUNT_SPILLS;
202 
203  disp = dst->vv.regoff;
204 
205  switch (dst->type) {
206  case TYPE_INT:
207  case TYPE_ADR:
208  M_IST(d, REG_SP, disp);
209  break;
210  case TYPE_LNG:
211  M_LST(d, REG_SP, disp);
212  break;
213  case TYPE_FLT:
214  M_FST(d, REG_SP, disp);
215  break;
216  case TYPE_DBL:
217  M_DST(d, REG_SP, disp);
218  break;
219  default:
220  vm_abort("emit_store: unknown type %d", dst->type);
221  break;
222  }
223  }
224 }
225 
226 
227 /* emit_store_low **************************************************************
228 
229  Emits a possible store of the low 32-bits of the destination
230  operand.
231 
232 *******************************************************************************/
233 
234 void emit_store_low(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
235 {
236  codegendata *cd;
237 
238  assert(dst->type == TYPE_LNG);
239 
240  /* get required compiler data */
241 
242  cd = jd->cd;
243 
244  if (IS_INMEMORY(dst->flags)) {
245  COUNT_SPILLS;
246  M_IST(GET_LOW_REG(d), REG_SP, dst->vv.regoff);
247  }
248 }
249 
250 
251 /* emit_store_high *************************************************************
252 
253  Emits a possible store of the high 32-bits of the destination
254  operand.
255 
256 *******************************************************************************/
257 
258 void emit_store_high(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
259 {
260  codegendata *cd;
261 
262  assert(dst->type == TYPE_LNG);
263 
264  /* get required compiler data */
265 
266  cd = jd->cd;
267 
268  if (IS_INMEMORY(dst->flags)) {
269  COUNT_SPILLS;
270  M_IST(GET_HIGH_REG(d), REG_SP, dst->vv.regoff + 4);
271  }
272 }
273 
274 
275 /* emit_copy *******************************************************************
276 
277  Generates a register/memory to register/memory copy.
278 
279 *******************************************************************************/
280 
281 void emit_copy(jitdata *jd, instruction *iptr)
282 {
283  codegendata *cd;
284  varinfo *src;
285  varinfo *dst;
286  s4 s1, d;
287 
288  /* get required compiler data */
289 
290  cd = jd->cd;
291 
292  /* get source and destination variables */
293 
294  src = VAROP(iptr->s1);
295  dst = VAROP(iptr->dst);
296 
297  if ((src->vv.regoff != dst->vv.regoff) ||
298  ((src->flags ^ dst->flags) & INMEMORY)) {
299 
300  if ((src->type == TYPE_RET) || (dst->type == TYPE_RET)) {
301  /* emit nothing, as the value won't be used anyway */
302  return;
303  }
304 
305  /* If one of the variables resides in memory, we can eliminate
306  the register move from/to the temporary register with the
307  order of getting the destination register and the load. */
308 
309  if (IS_INMEMORY(src->flags)) {
310  if (IS_LNG_TYPE(src->type))
311  d = codegen_reg_of_var(iptr->opc, dst, REG_ITMP12_PACKED);
312  else
313  d = codegen_reg_of_var(iptr->opc, dst, REG_ITMP1);
314 
315  s1 = emit_load(jd, iptr, src, d);
316  }
317  else {
318  if (IS_LNG_TYPE(src->type))
319  s1 = emit_load(jd, iptr, src, REG_ITMP12_PACKED);
320  else
321  s1 = emit_load(jd, iptr, src, REG_ITMP1);
322 
323  d = codegen_reg_of_var(iptr->opc, dst, s1);
324  }
325 
326  if (s1 != d) {
327  switch (src->type) {
328  case TYPE_INT:
329  case TYPE_ADR:
330  M_MOV(s1, d);
331  break;
332  case TYPE_LNG:
333  M_LNGMOVE(s1, d);
334  break;
335  case TYPE_FLT:
336  case TYPE_DBL:
337 /* M_FMOV(s1, d); */
338  break;
339  default:
340  vm_abort("emit_copy: unknown type %d", src->type);
341  break;
342  }
343  }
344 
345  emit_store(jd, iptr, dst, d);
346  }
347 }
348 
349 
350 /**
351  * Emits code updating the condition register by comparing one integer
352  * register to an immediate integer value.
353  */
354 void emit_icmp_imm(codegendata* cd, int reg, int32_t value)
355 {
356  M_CMP_IMM(value, reg);
357 }
358 
359 
360 /* emit_branch *****************************************************************
361 
362  Emits the code for conditional and unconditional branchs.
363 
364 *******************************************************************************/
365 
366 void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 options)
367 {
368  s4 branchdisp;
369 
370  /* ATTENTION: a displacement overflow cannot happen */
371 
372  /* check which branch to generate */
373 
374  if (condition == BRANCH_UNCONDITIONAL) {
375 
376  /* calculate the different displacements */
377 
378  branchdisp = disp - BRANCH_UNCONDITIONAL_SIZE;
379 
380  M_JMP_IMM(branchdisp);
381  }
382  else {
383  /* calculate the different displacements */
384 
385  branchdisp = disp - BRANCH_CONDITIONAL_SIZE;
386 
387  switch (condition) {
388  case BRANCH_EQ:
389  M_BEQ(branchdisp);
390  break;
391  case BRANCH_NE:
392  M_BNE(branchdisp);
393  break;
394  case BRANCH_LT:
395  M_BLT(branchdisp);
396  break;
397  case BRANCH_GE:
398  M_BGE(branchdisp);
399  break;
400  case BRANCH_GT:
401  M_BGT(branchdisp);
402  break;
403  case BRANCH_LE:
404  M_BLE(branchdisp);
405  break;
406  case BRANCH_ULT:
407  M_BB(branchdisp);
408  break;
409  case BRANCH_ULE:
410  M_BBE(branchdisp);
411  break;
412  case BRANCH_UGE:
413  M_BAE(branchdisp);
414  break;
415  case BRANCH_UGT:
416  M_BA(branchdisp);
417  break;
418  default:
419  vm_abort("emit_branch: unknown condition %d", condition);
420  break;
421  }
422  }
423 }
424 
425 
426 /* emit_arithmetic_check *******************************************************
427 
428  Emit an ArithmeticException check.
429 
430 *******************************************************************************/
431 
433 {
434  if (INSTRUCTION_MUST_CHECK(iptr)) {
435  M_TEST(reg);
436  M_BNE(6);
438  }
439 }
440 
441 
442 /* emit_arrayindexoutofbounds_check ********************************************
443 
444  Emit a ArrayIndexOutOfBoundsException check.
445 
446 *******************************************************************************/
447 
449 {
450  if (INSTRUCTION_MUST_CHECK(iptr)) {
452  M_CMP(REG_ITMP3, s2);
453  M_BB(6);
455  }
456 }
457 
458 
459 /* emit_arraystore_check *******************************************************
460 
461  Emit an ArrayStoreException check.
462 
463 *******************************************************************************/
464 
466 {
467  if (INSTRUCTION_MUST_CHECK(iptr)) {
469  M_BNE(6);
471  }
472 }
473 
474 
475 /* emit_classcast_check ********************************************************
476 
477  Emit a ClassCastException check.
478 
479 *******************************************************************************/
480 
481 void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 reg, s4 s1)
482 {
483  if (INSTRUCTION_MUST_CHECK(iptr)) {
484  switch (condition) {
485  case BRANCH_LE:
486  M_BGT(6);
487  break;
488  case BRANCH_GE:
489  M_BLT(6);
490  break;
491  case BRANCH_EQ:
492  M_BNE(6);
493  break;
494  case BRANCH_NE:
495  M_BEQ(6);
496  break;
497  case BRANCH_ULE:
498  M_BBE(6);
499  break;
500  default:
501  vm_abort("emit_classcast_check: unknown condition %d", condition);
502  break;
503  }
505  }
506 }
507 
508 
509 /* emit_nullpointer_check ******************************************************
510 
511  Emit a NullPointerException check.
512 
513 *******************************************************************************/
514 
516 {
517  if (INSTRUCTION_MUST_CHECK(iptr)) {
518  M_TEST(reg);
519  M_BNE(6);
521  }
522 }
523 
524 
525 /* emit_exception_check ********************************************************
526 
527  Emit an Exception check.
528 
529 *******************************************************************************/
530 
532 {
533  if (INSTRUCTION_MUST_CHECK(iptr)) {
535  M_BNE(6);
537  }
538 }
539 
540 
541 /* emit_trap_compiler **********************************************************
542 
543  Emit a trap instruction which calls the JIT compiler.
544 
545 *******************************************************************************/
546 
548 {
550 }
551 
553 {
555 }
556 
557 /* emit_trap_countdown *********************************************************
558 
559  Emit a countdown trap.
560 
561  counter....absolute address of the counter variable
562 
563 *******************************************************************************/
564 
565 void emit_trap_countdown(codegendata *cd, s4 *counter)
566 {
567  M_ISUB_IMM_MEMABS(1, (s4) counter);
568  M_BNS(6);
570 }
571 
572 /* emit_patcher_alignment ******************************************************
573 
574  Emit NOP to ensure placement at an even address.
575 
576 *******************************************************************************/
577 
579 {
580  if ((uintptr_t) cd->mcodeptr & 1)
581  M_NOP;
582 }
583 
584 
585 /* emit_trap *******************************************************************
586 
587  Emit a trap instruction and return the original machine code.
588 
589 *******************************************************************************/
590 
591 uint32_t emit_trap(codegendata *cd)
592 {
593  uint16_t mcode;
594 
595  /* Get machine code which is patched back in later. The
596  trap is 2 bytes long. */
597 
598  mcode = *((uint16_t *) cd->mcodeptr);
599 
600 #if 0
601  /* XXX this breaks GDB, so we disable it for now */
602  *(cd->mcodeptr++) = 0xcc;
603  M_INT3;
604 #else
605  M_UD2;
606 #endif
607 
608  return (uint32_t) mcode;
609 }
610 
611 
612 /**
613  * Generates synchronization code to enter a monitor.
614  */
615 void emit_monitor_enter(jitdata* jd, int32_t syncslot_offset)
616 {
617  int align_off;
618 
619  // Get required compiler data.
620  methodinfo* m = jd->m;
621  codegendata* cd = jd->cd;
622 
623  align_off = cd->stackframesize ? 4 : 0;
624 
625  if (m->flags & ACC_STATIC) {
627  }
628  else {
629  M_ALD(REG_ITMP1, REG_SP, cd->stackframesize * 8 + 4 + align_off);
630  M_TEST(REG_ITMP1);
631  M_BNE(6);
633  }
634 
635  M_AST(REG_ITMP1, REG_SP, syncslot_offset);
636  M_AST(REG_ITMP1, REG_SP, 0 * 4);
638  M_CALL(REG_ITMP3);
639 }
640 
641 
642 /**
643  * Generates synchronization code to leave a monitor.
644  */
645 void emit_monitor_exit(jitdata* jd, int32_t syncslot_offset)
646 {
647  // Get required compiler data.
648  methodinfo* m = jd->m;
649  codegendata* cd = jd->cd;
650 
651  M_ALD(REG_ITMP2, REG_SP, syncslot_offset);
652 
653  /* we need to save the proper return value */
654 
655  methoddesc* md = m->parseddesc;
656 
657  switch (md->returntype.type) {
658  case TYPE_INT:
659  case TYPE_ADR:
660  M_IST(REG_RESULT, REG_SP, syncslot_offset);
661  break;
662 
663  case TYPE_LNG:
664  M_LST(REG_RESULT_PACKED, REG_SP, syncslot_offset);
665  break;
666 
667  case TYPE_FLT:
668  emit_fstps_membase(cd, REG_SP, syncslot_offset);
669  break;
670 
671  case TYPE_DBL:
672  emit_fstpl_membase(cd, REG_SP, syncslot_offset);
673  break;
674 
675  case TYPE_VOID:
676  break;
677 
678  default:
679  assert(false);
680  break;
681  }
682 
683  M_AST(REG_ITMP2, REG_SP, 0);
685  M_CALL(REG_ITMP3);
686 
687  /* and now restore the proper return value */
688 
689  switch (md->returntype.type) {
690  case TYPE_INT:
691  case TYPE_ADR:
692  M_ILD(REG_RESULT, REG_SP, syncslot_offset);
693  break;
694 
695  case TYPE_LNG:
696  M_LLD(REG_RESULT_PACKED, REG_SP, syncslot_offset);
697  break;
698 
699  case TYPE_FLT:
700  emit_flds_membase(cd, REG_SP, syncslot_offset);
701  break;
702 
703  case TYPE_DBL:
704  emit_fldl_membase(cd, REG_SP, syncslot_offset);
705  break;
706 
707  case TYPE_VOID:
708  break;
709 
710  default:
711  assert(false);
712  break;
713  }
714 }
715 
716 
717 /**
718  * Emit profiling code for method frequency counting.
719  */
720 #if defined(ENABLE_PROFILING)
721 void emit_profile_method(codegendata* cd, codeinfo* code)
722 {
723  M_MOV_IMM(code, REG_ITMP3);
724  M_IADD_IMM_MEMBASE(1, REG_ITMP3, OFFSET(codeinfo, frequency));
725 }
726 #endif
727 
728 
729 /**
730  * Emit profiling code for basicblock frequency counting.
731  */
732 #if defined(ENABLE_PROFILING)
733 void emit_profile_basicblock(codegendata* cd, codeinfo* code, basicblock* bptr)
734 {
735  M_MOV_IMM(code->bbfrequency, REG_ITMP3);
736  M_IADD_IMM_MEMBASE(1, REG_ITMP3, bptr->nr * 4);
737 }
738 #endif
739 
740 
741 /**
742  * Emit profiling code to start CPU cycle counting.
743  */
744 #if defined(ENABLE_PROFILING)
745 void emit_profile_cycle_start(codegendata* cd, codeinfo* code)
746 {
747  // XXX Not implemented yet!
748 }
749 #endif
750 
751 
752 /**
753  * Emit profiling code to stop CPU cycle counting.
754  */
755 #if defined(ENABLE_PROFILING)
756 void emit_profile_cycle_stop(codegendata* cd, codeinfo* code)
757 {
758  // XXX Not implemented yet!
759 }
760 #endif
761 
762 
763 /* emit_verbosecall_enter ******************************************************
764 
765  Generates the code for the call trace.
766 
767 *******************************************************************************/
768 
769 #if !defined(NDEBUG)
771 {
772  methodinfo *m;
773  codeinfo *code;
774  codegendata *cd;
775  registerdata *rd;
776  //methoddesc *md;
777  int32_t stackframesize;
778  int i;
779  int align_off; /* offset for alignment compensation */
780 
782  return;
783 
784  /* get required compiler data */
785 
786  m = jd->m;
787  code = jd->code;
788  cd = jd->cd;
789  rd = jd->rd;
790 
791  //md = m->parseddesc;
792 
793  /* mark trace code */
794 
795  M_NOP;
796 
797  /* keep stack 16-byte aligned */
798 
799  stackframesize = 2 + TMP_CNT;
800  ALIGN_2(stackframesize);
801 
802  M_ASUB_IMM(stackframesize * 8, REG_SP);
803 
804  /* save temporary registers for leaf methods */
805 
806  if (code_is_leafmethod(code)) {
807  for (i = 0; i < INT_TMP_CNT; i++)
808  M_IST(rd->tmpintregs[i], REG_SP, (2 + i) * 8);
809  }
810 
811  /* no argument registers to save */
812 
813  align_off = cd->stackframesize ? 4 : 0;
814  M_AST_IMM(m, REG_SP, 0 * 4);
815  M_AST_IMM(0, REG_SP, 1 * 4);
816  M_AST(REG_SP, REG_SP, 2 * 4);
817  M_IADD_IMM_MEMBASE(stackframesize * 8 + cd->stackframesize * 8 + 4 + align_off, REG_SP, 2 * 4);
819  M_CALL(REG_ITMP1);
820 
821  /* no argument registers to restore */
822 
823  /* restore temporary registers for leaf methods */
824 
825  if (code_is_leafmethod(code)) {
826  for (i = 0; i < INT_TMP_CNT; i++)
827  M_ILD(rd->tmpintregs[i], REG_SP, (2 + i) * 8);
828  }
829 
830  M_AADD_IMM(stackframesize * 8, REG_SP);
831 
832  /* mark trace code */
833 
834  M_NOP;
835 }
836 #endif /* !defined(NDEBUG) */
837 
838 
839 /* emit_verbosecall_exit *******************************************************
840 
841  Generates the code for the call trace.
842 
843 *******************************************************************************/
844 
845 #if !defined(NDEBUG)
847 {
848  methodinfo *m;
849  codegendata *cd;
850  //registerdata *rd;
851  methoddesc *md;
852 
854  return;
855 
856  /* get required compiler data */
857 
858  m = jd->m;
859  cd = jd->cd;
860  //rd = jd->rd;
861 
862  md = m->parseddesc;
863 
864  /* mark trace code */
865 
866  M_NOP;
867 
868  /* keep stack 16-byte aligned */
869 
870  M_ASUB_IMM(4 + 4 + 8, REG_SP);
871 
872  /* save return value */
873 
874  switch (md->returntype.type) {
875  case TYPE_ADR:
876  case TYPE_INT:
877  M_IST(REG_RESULT, REG_SP, 2 * 4);
878  break;
879  case TYPE_LNG:
880  M_LST(REG_RESULT_PACKED, REG_SP, 2 * 4);
881  break;
882  case TYPE_FLT:
883  M_FSTNP(REG_NULL, REG_SP, 2 * 4);
884  break;
885  case TYPE_DBL:
886  M_DSTNP(REG_NULL, REG_SP, 2 * 4);
887  break;
888  case TYPE_VOID:
889  break;
890  default:
891  assert(false);
892  break;
893  }
894 
895  M_AST_IMM(m, REG_SP, 0 * 4);
896  M_AST(REG_SP, REG_SP, 1 * 4);
897  M_IADD_IMM_MEMBASE(2 * 4, REG_SP, 1 * 4);
899  M_CALL(REG_ITMP1);
900 
901  /* restore return value */
902 
903  switch (md->returntype.type) {
904  case TYPE_ADR:
905  case TYPE_INT:
906  M_ILD(REG_RESULT, REG_SP, 2 * 4);
907  break;
908  case TYPE_LNG:
909  M_LLD(REG_RESULT_PACKED, REG_SP, 2 * 4);
910  break;
911  case TYPE_VOID:
912  break;
913  default:
914  assert(false);
915  break;
916  }
917 
918  M_AADD_IMM(4 + 4 + 8, REG_SP);
919 
920  /* mark trace code */
921 
922  M_NOP;
923 }
924 #endif /* !defined(NDEBUG) */
925 
926 
927 /* code generation functions **************************************************/
928 
929 static void emit_membase(codegendata *cd, s4 basereg, s4 disp, s4 dreg)
930 {
931  if (basereg == ESP) {
932  if (disp == 0) {
933  emit_address_byte(0, dreg, ESP);
935  }
936  else if (IS_IMM8(disp)) {
937  emit_address_byte(1, dreg, ESP);
939  emit_imm8(disp);
940  }
941  else {
942  emit_address_byte(2, dreg, ESP);
944  emit_imm32(disp);
945  }
946  }
947  else if ((disp == 0) && (basereg != EBP)) {
948  emit_address_byte(0, dreg, basereg);
949  }
950  else if (IS_IMM8(disp)) {
951  emit_address_byte(1, dreg, basereg);
952  emit_imm8(disp);
953  }
954  else {
955  emit_address_byte(2, dreg, basereg);
956  emit_imm32(disp);
957  }
958 }
959 
960 
961 static void emit_membase32(codegendata *cd, s4 basereg, s4 disp, s4 dreg)
962 {
963  if (basereg == ESP) {
964  emit_address_byte(2, dreg, ESP);
966  emit_imm32(disp);
967  }
968  else {
969  emit_address_byte(2, dreg, basereg);
970  emit_imm32(disp);
971  }
972 }
973 
974 
975 static void emit_memindex(codegendata *cd, s4 reg, s4 disp, s4 basereg, s4 indexreg, s4 scale)
976 {
977  if (basereg == -1) {
978  emit_address_byte(0, reg, 4);
979  emit_address_byte(scale, indexreg, 5);
980  emit_imm32(disp);
981  }
982  else if ((disp == 0) && (basereg != EBP)) {
983  emit_address_byte(0, reg, 4);
984  emit_address_byte(scale, indexreg, basereg);
985  }
986  else if (IS_IMM8(disp)) {
987  emit_address_byte(1, reg, 4);
988  emit_address_byte(scale, indexreg, basereg);
989  emit_imm8(disp);
990  }
991  else {
992  emit_address_byte(2, reg, 4);
993  emit_address_byte(scale, indexreg, basereg);
994  emit_imm32(disp);
995  }
996 }
997 
998 
999 /* low-level code emitter functions *******************************************/
1000 
1001 void emit_mov_reg_reg(codegendata *cd, s4 reg, s4 dreg)
1002 {
1003  STATISTICS(count_mov_reg_reg++);
1004  *(cd->mcodeptr++) = 0x89;
1005  emit_reg((reg),(dreg));
1006 }
1007 
1008 
1009 void emit_mov_imm_reg(codegendata *cd, s4 imm, s4 reg)
1010 {
1011  *(cd->mcodeptr++) = 0xb8 + ((reg) & 0x07);
1012  emit_imm32((imm));
1013 }
1014 
1015 /* 2-byte opcode for use with patchers */
1016 void emit_mov_imm2_reg(codegendata *cd, s4 imm, s4 reg)
1017 {
1018  *(cd->mcodeptr++) = 0xc7;
1019  emit_address_byte(3, 0, reg);
1020  emit_imm32((imm));
1021 }
1022 
1023 
1024 
1025 void emit_movb_imm_reg(codegendata *cd, s4 imm, s4 reg)
1026 {
1027  *(cd->mcodeptr++) = 0xc6;
1028  emit_reg(0,(reg));
1029  emit_imm8((imm));
1030 }
1031 
1032 
1033 void emit_mov_membase_reg(codegendata *cd, s4 basereg, s4 disp, s4 reg)
1034 {
1035  STATISTICS(count_mov_mem_reg++);
1036  *(cd->mcodeptr++) = 0x8b;
1037  emit_membase(cd, (basereg),(disp),(reg));
1038 }
1039 
1040 
1041 /*
1042  * this one is for INVOKEVIRTUAL/INVOKEINTERFACE to have a
1043  * constant membase immediate length of 32bit
1044  */
1045 void emit_mov_membase32_reg(codegendata *cd, s4 basereg, s4 disp, s4 reg)
1046 {
1047  STATISTICS(count_mov_mem_reg++);
1048  *(cd->mcodeptr++) = 0x8b;
1049  emit_membase32(cd, (basereg),(disp),(reg));
1050 }
1051 
1052 
1053 void emit_mov_reg_membase(codegendata *cd, s4 reg, s4 basereg, s4 disp)
1054 {
1055  STATISTICS(count_mov_reg_mem++);
1056  *(cd->mcodeptr++) = 0x89;
1057  emit_membase(cd, (basereg),(disp),(reg));
1058 }
1059 
1060 
1061 void emit_mov_reg_membase32(codegendata *cd, s4 reg, s4 basereg, s4 disp)
1062 {
1063  STATISTICS(count_mov_reg_mem++);
1064  *(cd->mcodeptr++) = 0x89;
1065  emit_membase32(cd, (basereg),(disp),(reg));
1066 }
1067 
1068 
1069 void emit_mov_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
1070 {
1071  STATISTICS(count_mov_mem_reg++);
1072  *(cd->mcodeptr++) = 0x8b;
1073  emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
1074 }
1075 
1076 
1077 void emit_mov_reg_memindex(codegendata *cd, s4 reg, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1078 {
1079  STATISTICS(count_mov_reg_mem++);
1080  *(cd->mcodeptr++) = 0x89;
1081  emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
1082 }
1083 
1084 
1085 void emit_movw_reg_memindex(codegendata *cd, s4 reg, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1086 {
1087  STATISTICS(count_mov_reg_mem++);
1088  *(cd->mcodeptr++) = 0x66;
1089  *(cd->mcodeptr++) = 0x89;
1090  emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
1091 }
1092 
1093 
1094 void emit_movb_reg_memindex(codegendata *cd, s4 reg, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1095 {
1096  STATISTICS(count_mov_reg_mem++);
1097  *(cd->mcodeptr++) = 0x88;
1098  emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
1099 }
1100 
1101 
1102 void emit_mov_reg_mem(codegendata *cd, s4 reg, s4 mem)
1103 {
1104  STATISTICS(count_mov_reg_mem++);
1105  *(cd->mcodeptr++) = 0x89;
1106  emit_mem((reg),(mem));
1107 }
1108 
1109 
1110 void emit_mov_mem_reg(codegendata *cd, s4 mem, s4 dreg)
1111 {
1112  STATISTICS(count_mov_mem_reg++);
1113  *(cd->mcodeptr++) = 0x8b;
1114  emit_mem((dreg),(mem));
1115 }
1116 
1117 
1118 void emit_mov_imm_mem(codegendata *cd, s4 imm, s4 mem)
1119 {
1120  *(cd->mcodeptr++) = 0xc7;
1121  emit_mem(0, mem);
1122  emit_imm32(imm);
1123 }
1124 
1125 
1126 void emit_mov_imm_membase(codegendata *cd, s4 imm, s4 basereg, s4 disp)
1127 {
1128  *(cd->mcodeptr++) = 0xc7;
1129  emit_membase(cd, (basereg),(disp),0);
1130  emit_imm32((imm));
1131 }
1132 
1133 
1134 void emit_mov_imm_membase32(codegendata *cd, s4 imm, s4 basereg, s4 disp)
1135 {
1136  *(cd->mcodeptr++) = 0xc7;
1137  emit_membase32(cd, (basereg),(disp),0);
1138  emit_imm32((imm));
1139 }
1140 
1141 
1142 void emit_movb_imm_membase(codegendata *cd, s4 imm, s4 basereg, s4 disp)
1143 {
1144  *(cd->mcodeptr++) = 0xc6;
1145  emit_membase(cd, (basereg),(disp),0);
1146  emit_imm8((imm));
1147 }
1148 
1149 
1151 {
1152  assert(a < 4); /* Can only operate on al, bl, cl, dl. */
1153  *(cd->mcodeptr++) = 0x0f;
1154  *(cd->mcodeptr++) = 0xbe;
1155  emit_reg((b),(a));
1156 }
1157 
1158 
1159 void emit_movsbl_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
1160 {
1161  STATISTICS(count_mov_mem_reg++);
1162  *(cd->mcodeptr++) = 0x0f;
1163  *(cd->mcodeptr++) = 0xbe;
1164  emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
1165 }
1166 
1167 
1169 {
1170  *(cd->mcodeptr++) = 0x0f;
1171  *(cd->mcodeptr++) = 0xbf;
1172  emit_reg((b),(a));
1173 }
1174 
1175 
1176 void emit_movswl_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
1177 {
1178  STATISTICS(count_mov_mem_reg++);
1179  *(cd->mcodeptr++) = 0x0f;
1180  *(cd->mcodeptr++) = 0xbf;
1181  emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
1182 }
1183 
1184 
1186 {
1187  assert(a < 4); /* Can only operate on al, bl, cl, dl. */
1188  *(cd->mcodeptr++) = 0x0f;
1189  *(cd->mcodeptr++) = 0xb6;
1190  emit_reg((b),(a));
1191 }
1192 
1193 
1195 {
1196  *(cd->mcodeptr++) = 0x0f;
1197  *(cd->mcodeptr++) = 0xb7;
1198  emit_reg((b),(a));
1199 }
1200 
1201 
1202 void emit_movzwl_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
1203 {
1204  STATISTICS(count_mov_mem_reg++);
1205  *(cd->mcodeptr++) = 0x0f;
1206  *(cd->mcodeptr++) = 0xb7;
1207  emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
1208 }
1209 
1210 
1211 void emit_mov_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1212 {
1213  *(cd->mcodeptr++) = 0xc7;
1214  emit_memindex(cd, 0,(disp),(basereg),(indexreg),(scale));
1215  emit_imm32((imm));
1216 }
1217 
1218 
1219 void emit_movw_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1220 {
1221  *(cd->mcodeptr++) = 0x66;
1222  *(cd->mcodeptr++) = 0xc7;
1223  emit_memindex(cd, 0,(disp),(basereg),(indexreg),(scale));
1224  emit_imm16((imm));
1225 }
1226 
1227 
1228 void emit_movb_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1229 {
1230  *(cd->mcodeptr++) = 0xc6;
1231  emit_memindex(cd, 0,(disp),(basereg),(indexreg),(scale));
1232  emit_imm8((imm));
1233 }
1234 
1235 
1236 /*
1237  * alu operations
1238  */
1239 void emit_alu_reg_reg(codegendata *cd, s4 opc, s4 reg, s4 dreg)
1240 {
1241  *(cd->mcodeptr++) = (((u1) (opc)) << 3) + 1;
1242  emit_reg((reg),(dreg));
1243 }
1244 
1245 
1246 void emit_alu_reg_membase(codegendata *cd, s4 opc, s4 reg, s4 basereg, s4 disp)
1247 {
1248  *(cd->mcodeptr++) = (((u1) (opc)) << 3) + 1;
1249  emit_membase(cd, (basereg),(disp),(reg));
1250 }
1251 
1252 
1253 void emit_alu_membase_reg(codegendata *cd, s4 opc, s4 basereg, s4 disp, s4 reg)
1254 {
1255  *(cd->mcodeptr++) = (((u1) (opc)) << 3) + 3;
1256  emit_membase(cd, (basereg),(disp),(reg));
1257 }
1258 
1259 
1260 void emit_alu_imm_reg(codegendata *cd, s4 opc, s4 imm, s4 dreg)
1261 {
1262  if (IS_IMM8(imm)) {
1263  *(cd->mcodeptr++) = 0x83;
1264  emit_reg((opc),(dreg));
1265  emit_imm8((imm));
1266  } else {
1267  *(cd->mcodeptr++) = 0x81;
1268  emit_reg((opc),(dreg));
1269  emit_imm32((imm));
1270  }
1271 }
1272 
1273 
1274 void emit_alu_imm32_reg(codegendata *cd, s4 opc, s4 imm, s4 dreg)
1275 {
1276  *(cd->mcodeptr++) = 0x81;
1277  emit_reg((opc),(dreg));
1278  emit_imm32((imm));
1279 }
1280 
1281 
1282 void emit_alu_imm_membase(codegendata *cd, s4 opc, s4 imm, s4 basereg, s4 disp)
1283 {
1284  if (IS_IMM8(imm)) {
1285  *(cd->mcodeptr++) = 0x83;
1286  emit_membase(cd, (basereg),(disp),(opc));
1287  emit_imm8((imm));
1288  } else {
1289  *(cd->mcodeptr++) = 0x81;
1290  emit_membase(cd, (basereg),(disp),(opc));
1291  emit_imm32((imm));
1292  }
1293 }
1294 
1295 
1296 void emit_alu_imm_memabs(codegendata *cd, s4 opc, s4 imm, s4 disp)
1297 {
1298  if (IS_IMM8(imm)) {
1299  *(cd->mcodeptr++) = 0x83;
1300  emit_mem(opc, disp);
1301  emit_imm8((imm));
1302  } else {
1303  *(cd->mcodeptr++) = 0x81;
1304  emit_mem(opc, disp);
1305  emit_imm32((imm));
1306  }
1307 }
1308 
1309 void emit_alu_memindex_reg(codegendata *cd, s4 opc, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
1310 {
1311  *(cd->mcodeptr++) = (((u1) (opc)) << 3) + 3;
1312  emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
1313 }
1314 
1315 void emit_test_reg_reg(codegendata *cd, s4 reg, s4 dreg)
1316 {
1317  *(cd->mcodeptr++) = 0x85;
1318  emit_reg((reg),(dreg));
1319 }
1320 
1321 
1322 void emit_test_imm_reg(codegendata *cd, s4 imm, s4 reg)
1323 {
1324  *(cd->mcodeptr++) = 0xf7;
1325  emit_reg(0,(reg));
1326  emit_imm32((imm));
1327 }
1328 
1329 
1330 
1331 /*
1332  * inc, dec operations
1333  */
1335 {
1336  *(cd->mcodeptr++) = 0xff;
1337  emit_reg(0,(reg));
1338 }
1339 
1341 {
1342  *(cd->mcodeptr++) = 0xff;
1343  emit_mem(1,(mem));
1344 }
1345 
1346 
1347 void emit_imul_reg_reg(codegendata *cd, s4 reg, s4 dreg)
1348 {
1349  *(cd->mcodeptr++) = 0x0f;
1350  *(cd->mcodeptr++) = 0xaf;
1351  emit_reg((dreg),(reg));
1352 }
1353 
1354 
1355 void emit_imul_membase_reg(codegendata *cd, s4 basereg, s4 disp, s4 dreg)
1356 {
1357  *(cd->mcodeptr++) = 0x0f;
1358  *(cd->mcodeptr++) = 0xaf;
1359  emit_membase(cd, (basereg),(disp),(dreg));
1360 }
1361 
1362 
1363 void emit_imul_imm_reg(codegendata *cd, s4 imm, s4 dreg)
1364 {
1365  if (IS_IMM8((imm))) {
1366  *(cd->mcodeptr++) = 0x6b;
1367  emit_reg(0,(dreg));
1368  emit_imm8((imm));
1369  } else {
1370  *(cd->mcodeptr++) = 0x69;
1371  emit_reg(0,(dreg));
1372  emit_imm32((imm));
1373  }
1374 }
1375 
1376 
1377 void emit_imul_imm_reg_reg(codegendata *cd, s4 imm, s4 reg, s4 dreg)
1378 {
1379  if (IS_IMM8((imm))) {
1380  *(cd->mcodeptr++) = 0x6b;
1381  emit_reg((dreg),(reg));
1382  emit_imm8((imm));
1383  } else {
1384  *(cd->mcodeptr++) = 0x69;
1385  emit_reg((dreg),(reg));
1386  emit_imm32((imm));
1387  }
1388 }
1389 
1390 
1391 void emit_imul_imm_membase_reg(codegendata *cd, s4 imm, s4 basereg, s4 disp, s4 dreg)
1392 {
1393  if (IS_IMM8((imm))) {
1394  *(cd->mcodeptr++) = 0x6b;
1395  emit_membase(cd, (basereg),(disp),(dreg));
1396  emit_imm8((imm));
1397  } else {
1398  *(cd->mcodeptr++) = 0x69;
1399  emit_membase(cd, (basereg),(disp),(dreg));
1400  emit_imm32((imm));
1401  }
1402 }
1403 
1404 
1406 {
1407  *(cd->mcodeptr++) = 0xf7;
1408  emit_reg(4, reg);
1409 }
1410 
1411 
1412 void emit_mul_membase(codegendata *cd, s4 basereg, s4 disp)
1413 {
1414  *(cd->mcodeptr++) = 0xf7;
1415  emit_membase(cd, (basereg),(disp),4);
1416 }
1417 
1418 
1420 {
1421  *(cd->mcodeptr++) = 0xf7;
1422  emit_reg(7,(reg));
1423 }
1424 
1425 
1426 
1427 /*
1428  * shift ops
1429  */
1430 void emit_shift_reg(codegendata *cd, s4 opc, s4 reg)
1431 {
1432  *(cd->mcodeptr++) = 0xd3;
1433  emit_reg((opc),(reg));
1434 }
1435 
1436 
1437 void emit_shift_imm_reg(codegendata *cd, s4 opc, s4 imm, s4 dreg)
1438 {
1439  if ((imm) == 1) {
1440  *(cd->mcodeptr++) = 0xd1;
1441  emit_reg((opc),(dreg));
1442  } else {
1443  *(cd->mcodeptr++) = 0xc1;
1444  emit_reg((opc),(dreg));
1445  emit_imm8((imm));
1446  }
1447 }
1448 
1449 
1450 void emit_shld_reg_reg(codegendata *cd, s4 reg, s4 dreg)
1451 {
1452  *(cd->mcodeptr++) = 0x0f;
1453  *(cd->mcodeptr++) = 0xa5;
1454  emit_reg((reg),(dreg));
1455 }
1456 
1457 
1458 void emit_shld_imm_reg_reg(codegendata *cd, s4 imm, s4 reg, s4 dreg)
1459 {
1460  *(cd->mcodeptr++) = 0x0f;
1461  *(cd->mcodeptr++) = 0xa4;
1462  emit_reg((reg),(dreg));
1463  emit_imm8((imm));
1464 }
1465 
1466 
1467 void emit_shld_reg_membase(codegendata *cd, s4 reg, s4 basereg, s4 disp)
1468 {
1469  *(cd->mcodeptr++) = 0x0f;
1470  *(cd->mcodeptr++) = 0xa5;
1471  emit_membase(cd, (basereg),(disp),(reg));
1472 }
1473 
1474 
1475 void emit_shrd_reg_reg(codegendata *cd, s4 reg, s4 dreg)
1476 {
1477  *(cd->mcodeptr++) = 0x0f;
1478  *(cd->mcodeptr++) = 0xad;
1479  emit_reg((reg),(dreg));
1480 }
1481 
1482 
1483 void emit_shrd_imm_reg_reg(codegendata *cd, s4 imm, s4 reg, s4 dreg)
1484 {
1485  *(cd->mcodeptr++) = 0x0f;
1486  *(cd->mcodeptr++) = 0xac;
1487  emit_reg((reg),(dreg));
1488  emit_imm8((imm));
1489 }
1490 
1491 
1492 void emit_shrd_reg_membase(codegendata *cd, s4 reg, s4 basereg, s4 disp)
1493 {
1494  *(cd->mcodeptr++) = 0x0f;
1495  *(cd->mcodeptr++) = 0xad;
1496  emit_membase(cd, (basereg),(disp),(reg));
1497 }
1498 
1499 
1500 
1501 /*
1502  * jump operations
1503  */
1505 {
1506  *(cd->mcodeptr++) = 0xe9;
1507  emit_imm32((imm));
1508 }
1509 
1510 
1512 {
1513  *(cd->mcodeptr++) = 0xff;
1514  emit_reg(4,(reg));
1515 }
1516 
1517 
1518 void emit_jcc(codegendata *cd, s4 opc, s4 imm)
1519 {
1520  *(cd->mcodeptr++) = 0x0f;
1521  *(cd->mcodeptr++) = 0x80 + (u1) (opc);
1522  emit_imm32((imm));
1523 }
1524 
1525 
1526 
1527 /*
1528  * conditional set operations
1529  */
1530 void emit_setcc_reg(codegendata *cd, s4 opc, s4 reg)
1531 {
1532  assert(reg < 4); /* Can only operate on al, bl, cl, dl. */
1533  *(cd->mcodeptr++) = 0x0f;
1534  *(cd->mcodeptr++) = 0x90 + (u1) (opc);
1535  emit_reg(0,(reg));
1536 }
1537 
1538 
1539 void emit_setcc_membase(codegendata *cd, s4 opc, s4 basereg, s4 disp)
1540 {
1541  *(cd->mcodeptr++) = 0x0f;
1542  *(cd->mcodeptr++) = 0x90 + (u1) (opc);
1543  emit_membase(cd, (basereg),(disp),0);
1544 }
1545 
1546 
1547 void emit_xadd_reg_mem(codegendata *cd, s4 reg, s4 mem)
1548 {
1549  *(cd->mcodeptr++) = 0x0f;
1550  *(cd->mcodeptr++) = 0xc1;
1551  emit_mem((reg),(mem));
1552 }
1553 
1554 
1556 {
1557  *(cd->mcodeptr++) = 0xf7;
1558  emit_reg(3,(reg));
1559 }
1560 
1561 
1562 
1564 {
1565  *(cd->mcodeptr++) = 0x68;
1566  emit_imm32((imm));
1567 }
1568 
1569 
1571 {
1572  *(cd->mcodeptr++) = 0x58 + (0x07 & (u1) (reg));
1573 }
1574 
1575 
1577 {
1578  *(cd->mcodeptr++) = 0x50 + (0x07 & (u1) (reg));
1579 }
1580 
1581 
1583 {
1584  *(cd->mcodeptr++) = 0xf0;
1585 }
1586 
1587 
1588 /*
1589  * call instructions
1590  */
1592 {
1593  *(cd->mcodeptr++) = 0xff;
1594  emit_reg(2,(reg));
1595 }
1596 
1597 
1599 {
1600  *(cd->mcodeptr++) = 0xe8;
1601  emit_imm32((imm));
1602 }
1603 
1604 
1605 
1606 /*
1607  * floating point instructions
1608  */
1610 {
1611  *(cd->mcodeptr++) = 0xd9;
1612  *(cd->mcodeptr++) = 0xe8;
1613 }
1614 
1615 
1617 {
1618  *(cd->mcodeptr++) = 0xd9;
1619  *(cd->mcodeptr++) = 0xee;
1620 }
1621 
1622 
1624 {
1625  *(cd->mcodeptr++) = 0xd9;
1626  *(cd->mcodeptr++) = 0xc0 + (0x07 & (u1) (reg));
1627 }
1628 
1629 
1630 void emit_flds_membase(codegendata *cd, s4 basereg, s4 disp)
1631 {
1632  *(cd->mcodeptr++) = 0xd9;
1633  emit_membase(cd, (basereg),(disp),0);
1634 }
1635 
1636 
1637 void emit_flds_membase32(codegendata *cd, s4 basereg, s4 disp)
1638 {
1639  *(cd->mcodeptr++) = 0xd9;
1640  emit_membase32(cd, (basereg),(disp),0);
1641 }
1642 
1643 
1644 void emit_fldl_membase(codegendata *cd, s4 basereg, s4 disp)
1645 {
1646  *(cd->mcodeptr++) = 0xdd;
1647  emit_membase(cd, (basereg),(disp),0);
1648 }
1649 
1650 
1651 void emit_fldl_membase32(codegendata *cd, s4 basereg, s4 disp)
1652 {
1653  *(cd->mcodeptr++) = 0xdd;
1654  emit_membase32(cd, (basereg),(disp),0);
1655 }
1656 
1657 
1658 void emit_fldt_membase(codegendata *cd, s4 basereg, s4 disp)
1659 {
1660  *(cd->mcodeptr++) = 0xdb;
1661  emit_membase(cd, (basereg),(disp),5);
1662 }
1663 
1664 
1665 void emit_flds_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1666 {
1667  *(cd->mcodeptr++) = 0xd9;
1668  emit_memindex(cd, 0,(disp),(basereg),(indexreg),(scale));
1669 }
1670 
1671 
1672 void emit_fldl_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1673 {
1674  *(cd->mcodeptr++) = 0xdd;
1675  emit_memindex(cd, 0,(disp),(basereg),(indexreg),(scale));
1676 }
1677 
1678 
1680 {
1681  *(cd->mcodeptr++) = 0xd9;
1682  emit_mem(0,(mem));
1683 }
1684 
1685 
1687 {
1688  *(cd->mcodeptr++) = 0xdd;
1689  emit_mem(0,(mem));
1690 }
1691 
1692 
1693 void emit_fildl_membase(codegendata *cd, s4 basereg, s4 disp)
1694 {
1695  *(cd->mcodeptr++) = 0xdb;
1696  emit_membase(cd, (basereg),(disp),0);
1697 }
1698 
1699 
1700 void emit_fildll_membase(codegendata *cd, s4 basereg, s4 disp)
1701 {
1702  *(cd->mcodeptr++) = 0xdf;
1703  emit_membase(cd, (basereg),(disp),5);
1704 }
1705 
1706 
1708 {
1709  *(cd->mcodeptr++) = 0xdd;
1710  *(cd->mcodeptr++) = 0xd0 + (0x07 & (u1) (reg));
1711 }
1712 
1713 
1714 void emit_fsts_membase(codegendata *cd, s4 basereg, s4 disp)
1715 {
1716  *(cd->mcodeptr++) = 0xd9;
1717  emit_membase(cd, (basereg),(disp),2);
1718 }
1719 
1720 
1721 void emit_fstl_membase(codegendata *cd, s4 basereg, s4 disp)
1722 {
1723  *(cd->mcodeptr++) = 0xdd;
1724  emit_membase(cd, (basereg),(disp),2);
1725 }
1726 
1727 
1728 void emit_fsts_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1729 {
1730  *(cd->mcodeptr++) = 0xd9;
1731  emit_memindex(cd, 2,(disp),(basereg),(indexreg),(scale));
1732 }
1733 
1734 
1735 void emit_fstl_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1736 {
1737  *(cd->mcodeptr++) = 0xdd;
1738  emit_memindex(cd, 2,(disp),(basereg),(indexreg),(scale));
1739 }
1740 
1741 
1743 {
1744  *(cd->mcodeptr++) = 0xdd;
1745  *(cd->mcodeptr++) = 0xd8 + (0x07 & (u1) (reg));
1746 }
1747 
1748 
1749 void emit_fstps_membase(codegendata *cd, s4 basereg, s4 disp)
1750 {
1751  *(cd->mcodeptr++) = 0xd9;
1752  emit_membase(cd, (basereg),(disp),3);
1753 }
1754 
1755 
1756 void emit_fstps_membase32(codegendata *cd, s4 basereg, s4 disp)
1757 {
1758  *(cd->mcodeptr++) = 0xd9;
1759  emit_membase32(cd, (basereg),(disp),3);
1760 }
1761 
1762 
1763 void emit_fstpl_membase(codegendata *cd, s4 basereg, s4 disp)
1764 {
1765  *(cd->mcodeptr++) = 0xdd;
1766  emit_membase(cd, (basereg),(disp),3);
1767 }
1768 
1769 
1770 void emit_fstpl_membase32(codegendata *cd, s4 basereg, s4 disp)
1771 {
1772  *(cd->mcodeptr++) = 0xdd;
1773  emit_membase32(cd, (basereg),(disp),3);
1774 }
1775 
1776 
1777 void emit_fstpt_membase(codegendata *cd, s4 basereg, s4 disp)
1778 {
1779  *(cd->mcodeptr++) = 0xdb;
1780  emit_membase(cd, (basereg),(disp),7);
1781 }
1782 
1783 
1784 void emit_fstps_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1785 {
1786  *(cd->mcodeptr++) = 0xd9;
1787  emit_memindex(cd, 3,(disp),(basereg),(indexreg),(scale));
1788 }
1789 
1790 
1791 void emit_fstpl_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
1792 {
1793  *(cd->mcodeptr++) = 0xdd;
1794  emit_memindex(cd, 3,(disp),(basereg),(indexreg),(scale));
1795 }
1796 
1797 
1799 {
1800  *(cd->mcodeptr++) = 0xd9;
1801  emit_mem(3,(mem));
1802 }
1803 
1804 
1806 {
1807  *(cd->mcodeptr++) = 0xdd;
1808  emit_mem(3,(mem));
1809 }
1810 
1811 
1812 void emit_fistl_membase(codegendata *cd, s4 basereg, s4 disp)
1813 {
1814  *(cd->mcodeptr++) = 0xdb;
1815  emit_membase(cd, (basereg),(disp),2);
1816 }
1817 
1818 
1819 void emit_fistpl_membase(codegendata *cd, s4 basereg, s4 disp)
1820 {
1821  *(cd->mcodeptr++) = 0xdb;
1822  emit_membase(cd, (basereg),(disp),3);
1823 }
1824 
1825 
1826 void emit_fistpll_membase(codegendata *cd, s4 basereg, s4 disp)
1827 {
1828  *(cd->mcodeptr++) = 0xdf;
1829  emit_membase(cd, (basereg),(disp),7);
1830 }
1831 
1832 
1834 {
1835  *(cd->mcodeptr++) = 0xd9;
1836  *(cd->mcodeptr++) = 0xe0;
1837 }
1838 
1839 
1841 {
1842  *(cd->mcodeptr++) = 0xde;
1843  *(cd->mcodeptr++) = 0xc1;
1844 }
1845 
1846 
1848 {
1849  *(cd->mcodeptr++) = 0xd8;
1850  *(cd->mcodeptr++) = 0xc0 + (0x0f & (u1) (reg));
1851 }
1852 
1853 
1855 {
1856  *(cd->mcodeptr++) = 0xdc;
1857  *(cd->mcodeptr++) = 0xc0 + (0x0f & (u1) (reg));
1858 }
1859 
1860 
1862 {
1863  *(cd->mcodeptr++) = 0xde;
1864  *(cd->mcodeptr++) = 0xc0 + (0x0f & (u1) (reg));
1865 }
1866 
1867 
1868 void emit_fadds_membase(codegendata *cd, s4 basereg, s4 disp)
1869 {
1870  *(cd->mcodeptr++) = 0xd8;
1871  emit_membase(cd, (basereg),(disp),0);
1872 }
1873 
1874 
1875 void emit_faddl_membase(codegendata *cd, s4 basereg, s4 disp)
1876 {
1877  *(cd->mcodeptr++) = 0xdc;
1878  emit_membase(cd, (basereg),(disp),0);
1879 }
1880 
1881 
1883 {
1884  *(cd->mcodeptr++) = 0xd8;
1885  *(cd->mcodeptr++) = 0xe0 + (0x07 & (u1) (reg));
1886 }
1887 
1888 
1890 {
1891  *(cd->mcodeptr++) = 0xdc;
1892  *(cd->mcodeptr++) = 0xe8 + (0x07 & (u1) (reg));
1893 }
1894 
1895 
1897 {
1898  *(cd->mcodeptr++) = 0xde;
1899  *(cd->mcodeptr++) = 0xe8 + (0x07 & (u1) (reg));
1900 }
1901 
1902 
1904 {
1905  *(cd->mcodeptr++) = 0xde;
1906  *(cd->mcodeptr++) = 0xe9;
1907 }
1908 
1909 
1910 void emit_fsubs_membase(codegendata *cd, s4 basereg, s4 disp)
1911 {
1912  *(cd->mcodeptr++) = 0xd8;
1913  emit_membase(cd, (basereg),(disp),4);
1914 }
1915 
1916 
1917 void emit_fsubl_membase(codegendata *cd, s4 basereg, s4 disp)
1918 {
1919  *(cd->mcodeptr++) = 0xdc;
1920  emit_membase(cd, (basereg),(disp),4);
1921 }
1922 
1923 
1925 {
1926  *(cd->mcodeptr++) = 0xd8;
1927  *(cd->mcodeptr++) = 0xc8 + (0x07 & (u1) (reg));
1928 }
1929 
1930 
1932 {
1933  *(cd->mcodeptr++) = 0xdc;
1934  *(cd->mcodeptr++) = 0xc8 + (0x07 & (u1) (reg));
1935 }
1936 
1937 
1939 {
1940  *(cd->mcodeptr++) = 0xde;
1941  *(cd->mcodeptr++) = 0xc9;
1942 }
1943 
1944 
1946 {
1947  *(cd->mcodeptr++) = 0xde;
1948  *(cd->mcodeptr++) = 0xc8 + (0x07 & (u1) (reg));
1949 }
1950 
1951 
1952 void emit_fmuls_membase(codegendata *cd, s4 basereg, s4 disp)
1953 {
1954  *(cd->mcodeptr++) = 0xd8;
1955  emit_membase(cd, (basereg),(disp),1);
1956 }
1957 
1958 
1959 void emit_fmull_membase(codegendata *cd, s4 basereg, s4 disp)
1960 {
1961  *(cd->mcodeptr++) = 0xdc;
1962  emit_membase(cd, (basereg),(disp),1);
1963 }
1964 
1965 
1967 {
1968  *(cd->mcodeptr++) = 0xd8;
1969  *(cd->mcodeptr++) = 0xf0 + (0x07 & (u1) (reg));
1970 }
1971 
1972 
1974 {
1975  *(cd->mcodeptr++) = 0xdc;
1976  *(cd->mcodeptr++) = 0xf8 + (0x07 & (u1) (reg));
1977 }
1978 
1979 
1981 {
1982  *(cd->mcodeptr++) = 0xde;
1983  *(cd->mcodeptr++) = 0xf9;
1984 }
1985 
1986 
1988 {
1989  *(cd->mcodeptr++) = 0xde;
1990  *(cd->mcodeptr++) = 0xf8 + (0x07 & (u1) (reg));
1991 }
1992 
1993 
1995 {
1996  *(cd->mcodeptr++) = 0xd9;
1997  *(cd->mcodeptr++) = 0xc9;
1998 }
1999 
2000 
2002 {
2003  *(cd->mcodeptr++) = 0xd9;
2004  *(cd->mcodeptr++) = 0xc8 + (0x07 & (reg));
2005 }
2006 
2007 
2009 {
2010  *(cd->mcodeptr++) = 0xd9;
2011  *(cd->mcodeptr++) = 0xf8;
2012 }
2013 
2014 
2016 {
2017  *(cd->mcodeptr++) = 0xd9;
2018  *(cd->mcodeptr++) = 0xf5;
2019 }
2020 
2021 
2023 {
2024  *(cd->mcodeptr++) = 0xdd;
2025  *(cd->mcodeptr++) = 0xe1;
2026 }
2027 
2028 
2030 {
2031  *(cd->mcodeptr++) = 0xdd;
2032  *(cd->mcodeptr++) = 0xe0 + (0x07 & (u1) (reg));
2033 }
2034 
2035 
2037 {
2038  *(cd->mcodeptr++) = 0xdd;
2039  *(cd->mcodeptr++) = 0xe8 + (0x07 & (u1) (reg));
2040 }
2041 
2042 
2044 {
2045  *(cd->mcodeptr++) = 0xda;
2046  *(cd->mcodeptr++) = 0xe9;
2047 }
2048 
2049 
2051 {
2052  *(cd->mcodeptr++) = 0xdf;
2053  *(cd->mcodeptr++) = 0xe0;
2054 }
2055 
2056 
2058 {
2059  *(cd->mcodeptr++) = 0x9e;
2060 }
2061 
2062 
2064 {
2065  *(cd->mcodeptr++) = 0x9b;
2066  *(cd->mcodeptr++) = 0xdb;
2067  *(cd->mcodeptr++) = 0xe3;
2068 }
2069 
2070 
2072 {
2073  *(cd->mcodeptr++) = 0xd9;
2074  emit_mem(5,(mem));
2075 }
2076 
2077 
2078 void emit_fldcw_membase(codegendata *cd, s4 basereg, s4 disp)
2079 {
2080  *(cd->mcodeptr++) = 0xd9;
2081  emit_membase(cd, (basereg),(disp),5);
2082 }
2083 
2084 
2086 {
2087  *(cd->mcodeptr++) = 0x9b;
2088 }
2089 
2090 
2092 {
2093  *(cd->mcodeptr++) = 0xdd;
2094  *(cd->mcodeptr++) = 0xc0 + (0x07 & (u1) (reg));
2095 }
2096 
2097 
2099 {
2100  *(cd->mcodeptr++) = 0xd9;
2101  *(cd->mcodeptr++) = 0xf6;
2102 }
2103 
2104 
2106 {
2107  *(cd->mcodeptr++) = 0xd9;
2108  *(cd->mcodeptr++) = 0xf7;
2109 }
2110 
2111 #if defined(ENABLE_ESCAPE_CHECK)
2112 void emit_escape_check(codegendata *cd, s4 reg) {
2113  M_PUSH(reg);
2114  M_MOV_IMM(asm_escape_check, REG_ITMP3);
2115  M_CALL(REG_ITMP3);
2116  M_IADD_IMM(4, REG_SP);
2117 }
2118 #endif
2119 
2120 /*
2121  * These are local overrides for various environment variables in Emacs.
2122  * Please do not remove this and leave it at the end of the file, where
2123  * Emacs will automagically detect them.
2124  * ---------------------------------------------------------------------
2125  * Local variables:
2126  * mode: c++
2127  * indent-tabs-mode: t
2128  * c-basic-offset: 4
2129  * tab-width: 4
2130  * End:
2131  */
void emit_fsubs_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1910
#define emit_imm32(imm)
Definition: emit.hpp:123
#define REG_SP
Definition: md-abi.hpp:53
#define M_BBE(a)
Definition: codegen.hpp:307
void emit_imul_membase_reg(codegendata *cd, s4 basereg, s4 disp, s4 dreg)
Definition: emit.cpp:1355
#define emit_mem(r, mem)
Definition: emit.hpp:134
void emit_test_reg_reg(codegendata *cd, s4 reg, s4 dreg)
Definition: emit.cpp:1315
java_object_t header
Definition: class.hpp:73
#define GET_HIGH_REG(a)
union varinfo::@19 vv
void emit_fprem(codegendata *cd)
Definition: emit.cpp:2008
dummy_java_lang_Class object
Definition: class.hpp:88
void emit_imul_imm_membase_reg(codegendata *cd, s4 imm, s4 basereg, s4 disp, s4 dreg)
Definition: emit.cpp:1391
void emit_neg_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1555
void emit_setcc_reg(codegendata *cd, s4 opc, s4 reg)
Definition: emit.cpp:1530
void emit_mov_reg_memindex(codegendata *cd, s4 reg, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1077
void emit_fmul_st_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1931
#define M_ALD(a, b, disp)
Definition: codegen.hpp:345
#define STATISTICS(x)
Wrapper for statistics only code.
Definition: statistics.hpp:975
#define EBP
Definition: arch.hpp:56
void emit_movb_imm_reg(codegendata *cd, s4 imm, s4 reg)
Definition: emit.cpp:1025
#define ALIGN_2(a)
Definition: global.hpp:72
void emit_shrd_imm_reg_reg(codegendata *cd, s4 imm, s4 reg, s4 dreg)
Definition: emit.cpp:1483
Definition: jit.hpp:126
void emit_mov_membase_reg(codegendata *cd, s4 basereg, s4 disp, s4 reg)
Definition: emit.cpp:1033
void emit_fsubp_st_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1896
void emit_monitor_exit(jitdata *jd, int32_t syncslot_offset)
Generates synchronization code to leave a monitor.
Definition: emit.cpp:565
#define M_LST(a, b, disp)
Definition: codegen.hpp:349
void emit_flds_mem(codegendata *cd, s4 mem)
Definition: emit.cpp:1679
void emit_push_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1576
void emit_movw_reg_memindex(codegendata *cd, s4 reg, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1085
#define BRANCH_LE
void emit_fmull_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1959
void emit_mov_membase32_reg(codegendata *cd, s4 basereg, s4 disp, s4 reg)
Definition: emit.cpp:1045
#define JITDATA_HAS_FLAG_VERBOSECALL(jd)
Definition: jit.hpp:227
void emit_fchs(codegendata *cd)
Definition: emit.cpp:1833
#define M_BEQ(off)
Definition: codegen.hpp:482
#define M_ILD(a, b, disp)
Definition: codegen.hpp:347
void emit_alu_membase_reg(codegendata *cd, s4 opc, s4 basereg, s4 disp, s4 reg)
Definition: emit.cpp:1253
void emit_sahf(codegendata *cd)
Definition: emit.cpp:2057
void emit_flds_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1630
#define M_JMP_IMM(a)
Definition: codegen.hpp:316
#define M_CMP(a, b)
Definition: codegen.hpp:430
void emit_movzbl_reg_reg(codegendata *cd, s4 a, s4 b)
Definition: emit.cpp:1185
#define BRANCH_NE
#define M_IST(a, b, disp)
Definition: codegen.hpp:351
void emit_mov_mem_reg(codegendata *cd, s4 mem, s4 dreg)
Definition: emit.cpp:1110
void emit_push_imm(codegendata *cd, s4 imm)
Definition: emit.cpp:1563
#define M_BNE(off)
Definition: codegen.hpp:483
#define BRANCH_GT
void emit_shrd_reg_membase(codegendata *cd, s4 reg, s4 basereg, s4 disp)
Definition: emit.cpp:1492
void emit_monitor_enter(jitdata *jd, int32_t syncslot_offset)
Generates synchronization code to enter a monitor.
Definition: emit.cpp:507
void emit_shld_imm_reg_reg(codegendata *cd, s4 imm, s4 reg, s4 dreg)
Definition: emit.cpp:1458
#define BRANCH_EQ
#define M_AADD_IMM(a, b, c)
Definition: codegen.hpp:277
static void emit_membase32(codegendata *cd, s4 basereg, s4 disp, s4 dreg)
Definition: emit.cpp:961
#define M_DSTNP(a, b, disp)
Definition: codegen.hpp:332
void emit_fsub_st_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1889
void emit_fildll_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1700
codeinfo * code
Definition: jit.hpp:128
void emit_fdivp_st_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1987
#define REG_ITMP12_PACKED
Definition: md-abi.hpp:131
#define REG_NULL
Definition: md-abi.hpp:43
void emit_finit(codegendata *cd)
Definition: emit.cpp:2063
void emit_alu_imm_memabs(codegendata *cd, s4 opc, s4 imm, s4 disp)
Definition: emit.cpp:1296
s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum)
void emit_mov_reg_membase32(codegendata *cd, s4 reg, s4 basereg, s4 disp)
Definition: emit.cpp:1061
void emit_mov_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1211
#define BRANCH_UNCONDITIONAL
void emit_fistl_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1812
void emit_movb_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1228
void emit_alu_reg_reg(codegendata *cd, s4 opc, s4 reg, s4 dreg)
Definition: emit.cpp:1239
void emit_store_low(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
Definition: emit.cpp:234
#define M_PUSH(a)
Definition: codegen.hpp:248
#define M_BAE(a)
Definition: codegen.hpp:308
codegendata * cd
Definition: jit.hpp:129
#define ESP
Definition: arch.hpp:55
void emit_fmuls_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1952
void emit_fldl_membase32(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1651
void emit_fadds_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1868
void emit_arraystore_check(codegendata *cd, instruction *iptr)
Definition: emit.cpp:380
#define BRANCH_UNCONDITIONAL_SIZE
Definition: codegen.hpp:105
#define M_FST(a, b, disp)
Definition: codegen.hpp:357
#define M_FLD(a, b, disp)
Definition: codegen.hpp:354
uint8_t u1
Definition: types.hpp:40
#define COUNT_SPILLS
Definition: jit.hpp:108
void trace_java_call_exit(methodinfo *m, uint64_t *return_regs)
Definition: trace.cpp:240
Type type
Definition: reg.hpp:44
void emit_jmp_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1511
#define M_TEST(a)
Definition: codegen.hpp:359
void emit_fucompp(codegendata *cd)
Definition: emit.cpp:2043
void emit_faddp_st_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1861
void emit_alu_imm_membase(codegendata *cd, s4 opc, s4 imm, s4 basereg, s4 disp)
Definition: emit.cpp:1282
void emit_fdivp(codegendata *cd)
Definition: emit.cpp:1980
void emit_call_imm(codegendata *cd, s4 imm)
Definition: emit.cpp:1598
void emit_fstps_mem(codegendata *cd, s4 mem)
Definition: emit.cpp:1798
JNIEnv jthread jobject jclass jlong size
Definition: jvmti.h:387
Definition: reg.hpp:43
void emit_movzwl_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
Definition: emit.cpp:1202
void emit_fistpll_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1826
void emit_abstractmethoderror_trap(codegendata *cd)
Definition: emit.cpp:468
void emit_shld_reg_reg(codegendata *cd, s4 reg, s4 dreg)
Definition: emit.cpp:1450
void emit_fstpl_membase32(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1770
static int code_is_leafmethod(codeinfo *code)
Definition: code.hpp:151
void emit_fld1(codegendata *cd)
Definition: emit.cpp:1609
void emit_setcc_membase(codegendata *cd, s4 opc, s4 basereg, s4 disp)
Definition: emit.cpp:1539
void vm_abort(const char *text,...)
Definition: vm.cpp:2586
s4 regoff
Definition: reg.hpp:47
void emit_imul_imm_reg(codegendata *cd, s4 imm, s4 dreg)
Definition: emit.cpp:1363
void emit_fst_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1707
void emit_xadd_reg_mem(codegendata *cd, s4 reg, s4 mem)
Definition: emit.cpp:1547
void emit_verbosecall_enter(jitdata *jd)
Definition: emit.cpp:625
void emit_fsts_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1728
#define M_CMP_IMM(a, i)
Definition: codegen.hpp:446
void emit_exception_check(codegendata *cd, instruction *iptr)
Definition: emit.cpp:447
#define emit_reg(reg, rm)
Definition: emit.hpp:143
#define M_MOV_IMM(d, i)
Definition: codegen.hpp:448
#define GET_LOW_REG(a)
void emit_dec_mem(codegendata *cd, s4 mem)
Definition: emit.cpp:1340
void emit_fstps_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1749
void emit_fucomp_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:2036
void emit_mul_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1412
void emit_test_imm_reg(codegendata *cd, s4 imm, s4 reg)
Definition: emit.cpp:1322
void emit_store_high(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
Definition: emit.cpp:258
void emit_fldl_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1644
void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack)
Definition: trace.cpp:149
void emit_fstpl_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1763
void emit_fsubp(codegendata *cd)
Definition: emit.cpp:1903
#define M_FSTNP(a, b, disp)
Definition: codegen.hpp:331
void emit_fadd_reg_st(codegendata *cd, s4 reg)
Definition: emit.cpp:1847
void emit_fstp_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1742
void emit_call_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1591
void emit_movb_reg_memindex(codegendata *cd, s4 reg, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1094
void emit_imul_reg_reg(codegendata *cd, s4 reg, s4 dreg)
Definition: emit.cpp:1347
void emit_flds_membase32(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1637
void emit_mul_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1405
s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
Definition: emit.cpp:174
dst_operand_t dst
void emit_movsbl_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
Definition: emit.cpp:1159
#define LOCK_monitor_enter
Definition: builtin.hpp:124
classinfo * clazz
Definition: method.hpp:80
#define M_BNS(a)
Definition: codegen.hpp:310
void emit_fldcw_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:2078
void emit_mov_imm_membase32(codegendata *cd, s4 imm, s4 basereg, s4 disp)
Definition: emit.cpp:1134
This file contains the statistics framework.
void emit_movswl_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
Definition: emit.cpp:1176
void emit_fmulp(codegendata *cd)
Definition: emit.cpp:1938
#define M_LNGMOVE(a, b)
#define BRANCH_GE
void emit_fucom(codegendata *cd)
Definition: emit.cpp:2022
void emit_shift_reg(codegendata *cd, s4 opc, s4 reg)
Definition: emit.cpp:1430
void emit_fxch_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:2001
void emit_trap_compiler(codegendata *cd)
Definition: emit.cpp:463
void emit_shrd_reg_reg(codegendata *cd, s4 reg, s4 dreg)
Definition: emit.cpp:1475
void emit_flds_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1665
void emit_imul_imm_reg_reg(codegendata *cd, s4 imm, s4 reg, s4 dreg)
Definition: emit.cpp:1377
void emit_mov_imm_mem(codegendata *cd, s4 imm, s4 mem)
Definition: emit.cpp:1118
#define BRANCH_UGE
void emit_fdiv_st_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1973
#define M_ASUB_IMM(a, b, c)
Definition: codegen.hpp:278
void emit_fstl_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1721
void emit_trap(codegendata *cd, u1 Xd, int type)
Definition: emit-asm.hpp:563
MIIterator i
s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
Definition: emit.cpp:66
void emit_ffree_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:2091
#define BRANCH_UGT
typedesc returntype
Definition: descriptor.hpp:166
void emit_mov_imm2_reg(codegendata *cd, s4 imm, s4 reg)
Definition: emit.cpp:1016
#define M_BGE(off)
Definition: codegen.hpp:484
void emit_fldl_mem(codegendata *cd, s4 mem)
Definition: emit.cpp:1686
int32_t s4
Definition: types.hpp:45
void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
Definition: emit.cpp:113
void emit_fmulp_st_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1945
registerdata * rd
Definition: jit.hpp:130
#define M_AST(a, b, disp)
Definition: codegen.hpp:350
void emit_wait(codegendata *cd)
Definition: emit.cpp:2085
#define M_BB(a)
Definition: codegen.hpp:306
void emit_mov_imm_reg(codegendata *cd, s4 imm, s4 reg)
Definition: emit.cpp:1009
void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg)
Definition: emit.cpp:346
void emit_mov_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
Definition: emit.cpp:1069
void emit_alu_reg_membase(codegendata *cd, s4 opc, s4 reg, s4 basereg, s4 disp)
Definition: emit.cpp:1246
#define IS_IMM8(c)
Definition: emit-common.hpp:63
void emit_fsub_reg_st(codegendata *cd, s4 reg)
Definition: emit.cpp:1882
#define LOCK_monitor_exit
Definition: builtin.hpp:132
void emit_mov_reg_reg(codegendata *cd, s4 reg, s4 dreg)
Definition: emit.cpp:1001
#define M_MOV(a, b)
Definition: codegen.hpp:340
#define REG_ITMP2
Definition: md-abi.hpp:47
void emit_icmp_imm(codegendata *cd, int reg, int32_t value)
Emits code comparing a single register.
Definition: emit.cpp:243
void emit_fprem1(codegendata *cd)
Definition: emit.cpp:2015
void emit_copy(jitdata *jd, instruction *iptr)
Definition: emit.cpp:153
s1_operand_t s1
#define TMP_CNT
Definition: abi-asm.hpp:42
#define IS_LNG_TYPE(a)
Definition: global.hpp:135
uint32_t u4
Definition: types.hpp:46
void emit_alu_imm_reg(codegendata *cd, s4 opc, s4 imm, s4 dreg)
Definition: emit.cpp:1260
#define BRANCH_LT
#define INT_TMP_CNT
Definition: md-abi.hpp:75
void emit_movswl_reg_reg(codegendata *cd, s4 a, s4 b)
Definition: emit.cpp:1168
void emit_fldz(codegendata *cd)
Definition: emit.cpp:1616
void emit_fstps_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1784
#define M_BGT(off)
Definition: codegen.hpp:485
void emit_alu_memindex_reg(codegendata *cd, s4 opc, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
Definition: emit.cpp:1309
methoddesc * parseddesc
Definition: method.hpp:78
void emit_fadd_st_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1854
#define VAROP(v)
Definition: jit.hpp:251
int * tmpintregs
Definition: reg.hpp:70
void emit_movzwl_reg_reg(codegendata *cd, s4 a, s4 b)
Definition: emit.cpp:1194
methodinfo * m
Definition: jit.hpp:127
static bool IS_INMEMORY(s4 flags)
Definition: stack.hpp:51
void emit_jcc(codegendata *cd, s4 opc, s4 imm)
Definition: emit.cpp:1518
void emit_fstl_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1735
void emit_fucom_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:2029
s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
Definition: emit.cpp:136
void emit_fmul_reg_st(codegendata *cd, s4 reg)
Definition: emit.cpp:1924
void emit_patcher_alignment(codegendata *cd)
Definition: emit.cpp:578
void emit_pop_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1570
void emit_movw_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1219
void emit_fsts_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1714
void emit_mov_imm_membase(codegendata *cd, s4 imm, s4 basereg, s4 disp)
Definition: emit.cpp:1126
#define M_ISUB_IMM_MEMABS(a, b)
Definition: codegen.hpp:220
s4 flags
Definition: reg.hpp:45
#define M_BLT(off)
Definition: codegen.hpp:486
void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 reg, s4 s1)
Definition: emit.cpp:396
#define REG_METHODPTR
Definition: md-abi.hpp:43
void emit_lock(codegendata *cd)
Definition: emit.cpp:1582
void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt)
Definition: emit.cpp:263
void emit_fxch(codegendata *cd)
Definition: emit.cpp:1994
void emit_faddl_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1875
s4 nr
Definition: jit.hpp:312
void emit_fstpl_mem(codegendata *cd, s4 mem)
Definition: emit.cpp:1805
int8_t s1
Definition: types.hpp:39
void emit_movb_imm_membase(codegendata *cd, s4 imm, s4 basereg, s4 disp)
Definition: emit.cpp:1142
void emit_mov_reg_membase(codegendata *cd, s4 reg, s4 basereg, s4 disp)
Definition: emit.cpp:1053
void emit_jmp_imm(codegendata *cd, s4 imm)
Definition: emit.cpp:1504
int16_t s2
Definition: types.hpp:42
#define M_DST(a, b, disp)
Definition: codegen.hpp:356
void emit_shld_reg_membase(codegendata *cd, s4 reg, s4 basereg, s4 disp)
Definition: emit.cpp:1467
void emit_shift_imm_reg(codegendata *cd, s4 opc, s4 imm, s4 dreg)
Definition: emit.cpp:1437
#define BRANCH_ULE
void emit_alu_imm32_reg(codegendata *cd, s4 opc, s4 imm, s4 dreg)
Definition: emit.cpp:1274
void emit_fstpt_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1777
void emit_fildl_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1693
void emit_fincstp(codegendata *cd)
Definition: emit.cpp:2105
#define M_LLD(a, b, disp)
Definition: codegen.hpp:344
void emit_faddp(codegendata *cd)
Definition: emit.cpp:1840
#define BRANCH_ULT
void emit_inc_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1334
#define REG_ITMP3
Definition: md-abi.hpp:48
void emit_fdecstp(codegendata *cd)
Definition: emit.cpp:2098
void emit_fstpl_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1791
void emit_fldt_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1658
#define M_BLE(off)
Definition: codegen.hpp:487
void emit_mov_reg_mem(codegendata *cd, s4 reg, s4 mem)
Definition: emit.cpp:1102
static void emit_memindex(codegendata *cd, s4 reg, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:975
void emit_fistpl_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1819
s4 flags
Definition: method.hpp:70
#define M_IADD_IMM(a, b, c)
Definition: codegen.hpp:270
#define M_ALD_MEM(a, disp)
Definition: codegen.hpp:152
#define M_NOP
Definition: codegen.hpp:338
#define emit_address_byte(mod, reg, rm)
Definition: emit.hpp:102
void emit_fldl_memindex(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale)
Definition: emit.cpp:1672
void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2)
Definition: emit.cpp:362
#define M_UD2
Definition: codegen.hpp:319
void emit_fldcw_mem(codegendata *cd, s4 mem)
Definition: emit.cpp:2071
#define M_DLD(a, b, disp)
Definition: codegen.hpp:353
void emit_fdiv_reg_st(codegendata *cd, s4 reg)
Definition: emit.cpp:1966
void emit_idiv_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1419
#define M_CALL(a)
Definition: codegen.hpp:290
#define STAT_DECLARE_VAR(type, var, init)
Declare an external statistics variable.
Definition: statistics.hpp:963
void emit_verbosecall_exit(jitdata *jd)
Definition: emit.cpp:766
void emit_trap_countdown(codegendata *cd, s4 *counter)
Definition: emit.cpp:565
void emit_fnstsw(codegendata *cd)
Definition: emit.cpp:2050
void emit_fstps_membase32(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1756
static void emit_membase(codegendata *cd, s4 basereg, s4 disp, s4 dreg)
Definition: emit.cpp:929
#define OFFSET(s, el)
Definition: memory.hpp:90
#define emit_imm8(imm)
Definition: emit.hpp:108
#define INSTRUCTION_MUST_CHECK(iptr)
void emit_fsubl_membase(codegendata *cd, s4 basereg, s4 disp)
Definition: emit.cpp:1917
void emit_fld_reg(codegendata *cd, s4 reg)
Definition: emit.cpp:1623
#define REG_RESULT
Definition: md-abi.hpp:33
#define M_AST_IMM(a, b, disp)
Definition: codegen.hpp:175
#define M_BA(a)
Definition: codegen.hpp:309
#define BRANCH_CONDITIONAL_SIZE
Definition: codegen.hpp:106
void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg)
Definition: emit.cpp:431
#define emit_imm16(imm)
Definition: emit.hpp:114
#define REG_ITMP1
Definition: md-abi.hpp:46
#define REG_RESULT_PACKED
Definition: md-abi.hpp:133
void emit_movsbl_reg_reg(codegendata *cd, s4 a, s4 b)
Definition: emit.cpp:1150
#define M_IADD_IMM_MEMBASE(a, b, c)
Definition: codegen.hpp:218