* configure.ac: Added option --enable-replacement.
[cacao.git] / src / vm / jit / i386 / codegen.c
index 4cafff2d7a69e5f077d4ecc2f6b21ba5b87d7015..fb557a460e537fc08c05681b757750495d04d8a9 100644 (file)
 
    Authors: Andreas Krall
             Christian Thalinger
-
-   Changes: Joseph Wenninger
+            Joseph Wenninger
             Christian Ullrich
-                       Edwin Steiner
+            Edwin Steiner
 
-   $Id: codegen.c 5237 2006-08-15 14:54:25Z christian $
+   $Id: codegen.c 6264 2007-01-02 19:40:18Z edwin $
 
 */
 
@@ -46,7 +45,7 @@
 #include "vm/jit/i386/md-abi.h"
 
 #include "vm/jit/i386/codegen.h"
-#include "vm/jit/i386/md-emit.h"
+#include "vm/jit/i386/emit.h"
 
 #include "mm/memory.h"
 #include "native/jni.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit.h"
+#include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
 
-#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
-# include "vm/jit/allocator/lsra.h"
-#endif
 #if defined(ENABLE_SSA)
 # include "vm/jit/optimizing/lsra.h"
 # include "vm/jit/optimizing/ssa.h"
+#elif defined(ENABLE_LSRA)
+# include "vm/jit/allocator/lsra.h"
 #endif
 
 
@@ -92,8 +90,7 @@
 #if defined(ENABLE_SSA)
 void cg_move(codegendata *cd, s4 type, s4 src_regoff, s4 src_flags,
                         s4 dst_regoff, s4 dst_flags);
-void codegen_insert_phi_moves(codegendata *cd, registerdata *rd, lsradata *ls,
-                                                         basicblock *bptr);
+void codegen_insert_phi_moves(jitdata *jd, basicblock *bptr);
 #endif
 
 bool codegen(jitdata *jd)
@@ -102,18 +99,17 @@ bool codegen(jitdata *jd)
        codeinfo           *code;
        codegendata        *cd;
        registerdata       *rd;
-       s4                  len, s1, s2, s3, d, off, disp;
-       s4                  stackframesize;
-       stackptr            src;
-       varinfo            *var;
+       s4                  len, s1, s2, s3, d, disp;
+       varinfo            *var, *var1;
        basicblock         *bptr;
        instruction        *iptr;
-       exceptiontable     *ex;
+       exception_entry    *ex;
        u2                  currentline;
        methodinfo         *lm;             /* local methodinfo for ICMD_INVOKE*  */
        builtintable_entry *bte;
        methoddesc         *md;
-       rplpoint           *replacementpoint;
+       s4                 fieldtype;
+       s4                 varindex;
 #if defined(ENABLE_SSA)
        lsradata *ls;
        bool last_cmd_was_goto;
@@ -149,7 +145,7 @@ bool codegen(jitdata *jd)
        /* float register are saved on 2 4-byte stackslots */
        savedregs_num += (FLT_SAV_CNT - rd->savfltreguse) * 2;
 
-       stackframesize = rd->memuse + savedregs_num;
+       cd->stackframesize = rd->memuse + savedregs_num;
 
           
 #if defined(ENABLE_THREADS)
@@ -159,9 +155,9 @@ bool codegen(jitdata *jd)
                /* reserve 2 slots for long/double return values for monitorexit */
 
                if (IS_2_WORD_TYPE(m->parseddesc->returntype.type))
-                       stackframesize += 2;
+                       cd->stackframesize += 2;
                else
-                       stackframesize++;
+                       cd->stackframesize++;
        }
 #endif
 
@@ -170,10 +166,10 @@ bool codegen(jitdata *jd)
     /* Keep stack of non-leaf functions 16-byte aligned. */
 
        if (!jd->isleafmethod)
-               stackframesize |= 0x3;
+               cd->stackframesize |= 0x3;
 
-       (void) dseg_addaddress(cd, code);                      /* CodeinfoPointer */
-       (void) dseg_adds4(cd, stackframesize * 4);             /* FrameSize       */
+       (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
+       (void) dseg_add_unique_s4(cd, cd->stackframesize * 4); /* FrameSize       */
 
 #if defined(ENABLE_THREADS)
        /* IsSync contains the offset relative to the stack pointer for the
@@ -183,14 +179,14 @@ bool codegen(jitdata *jd)
        */
 
        if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               (void) dseg_adds4(cd, (rd->memuse + 1) * 4);       /* IsSync          */
+               (void) dseg_add_unique_s4(cd, (rd->memuse + 1) * 4); /* IsSync        */
        else
 #endif
-               (void) dseg_adds4(cd, 0);                          /* IsSync          */
+               (void) dseg_add_unique_s4(cd, 0);                  /* IsSync          */
                                               
-       (void) dseg_adds4(cd, jd->isleafmethod);               /* IsLeaf          */
-       (void) dseg_adds4(cd, INT_SAV_CNT - rd->savintreguse); /* IntSave         */
-       (void) dseg_adds4(cd, FLT_SAV_CNT - rd->savfltreguse); /* FltSave         */
+       (void) dseg_add_unique_s4(cd, jd->isleafmethod);       /* IsLeaf          */
+       (void) dseg_add_unique_s4(cd, INT_SAV_CNT - rd->savintreguse); /* IntSave */
+       (void) dseg_add_unique_s4(cd, FLT_SAV_CNT - rd->savfltreguse); /* FltSave */
 
        /* adds a reference for the length of the line number counter. We don't
           know the size yet, since we evaluate the information during code
@@ -199,15 +195,15 @@ bool codegen(jitdata *jd)
           to the information gotten from the class file */
        (void) dseg_addlinenumbertablesize(cd);
 
-       (void) dseg_adds4(cd, cd->exceptiontablelength);       /* ExTableSize     */
+       (void) dseg_add_unique_s4(cd, jd->exceptiontablelength); /* ExTableSize   */
        
        /* create exception table */
 
-       for (ex = cd->exceptiontable; ex != NULL; ex = ex->down) {
-               dseg_addtarget(cd, ex->start);
-               dseg_addtarget(cd, ex->end);
-               dseg_addtarget(cd, ex->handler);
-               (void) dseg_addaddress(cd, ex->catchtype.cls);
+       for (ex = jd->exceptiontable; ex != NULL; ex = ex->down) {
+               dseg_add_target(cd, ex->start);
+               dseg_add_target(cd, ex->end);
+               dseg_add_target(cd, ex->handler);
+               (void) dseg_add_unique_address(cd, ex->catchtype.any);
        }
        
        /* generate method profiling code */
@@ -221,12 +217,12 @@ bool codegen(jitdata *jd)
 
        /* create stack frame (if necessary) */
 
-       if (stackframesize)
-               M_ASUB_IMM(stackframesize * 4, REG_SP);
+       if (cd->stackframesize)
+               M_ASUB_IMM(cd->stackframesize * 4, REG_SP);
 
        /* save return address and used callee saved registers */
 
-       p = stackframesize;
+       p = cd->stackframesize;
        for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--) {
                p--; M_AST(rd->savintregs[i], REG_SP, p * 4);
        }
@@ -241,17 +237,22 @@ bool codegen(jitdata *jd)
        stack_off = 0;
        for (p = 0, l = 0; p < md->paramcount; p++) {
                t = md->paramtypes[p].type;
+
 #if defined(ENABLE_SSA)
                if ( ls != NULL ) {
                        l = ls->local_0[p];
                }
 #endif
-               var = &(rd->locals[l][t]);
+               varindex = jd->local_map[l * 5 + t];
                l++;
                if (IS_2_WORD_TYPE(t))    /* increment local counter for 2 word types */
                        l++;
-               if (var->type < 0)
+
+               if (varindex == UNUSED)
                        continue;
+
+               var = VAR(varindex);
+               
                s1 = md->params[p].regoff;
 
                if (IS_INT_LNG_TYPE(t)) {                    /* integer args          */
@@ -259,16 +260,16 @@ bool codegen(jitdata *jd)
                                log_text("integer register argument");
                                assert(0);
                                if (!(var->flags & INMEMORY)) {      /* reg arg -> register   */
-                                       /* rd->argintregs[md->params[p].regoff -> var->regoff     */
+                                       /* rd->argintregs[md->params[p].regoff -> var->vv.regoff     */
                                } 
                                else {                               /* reg arg -> spilled    */
-                                       /* rd->argintregs[md->params[p].regoff -> var->regoff * 4 */
+                                       /* rd->argintregs[md->params[p].regoff -> var->vv.regoff * 4 */
                                }
                        } 
                        else {                                   /* stack arguments       */
                                if (!(var->flags & INMEMORY)) {      /* stack arg -> register */
                                        emit_mov_membase_reg(           /* + 4 for return address */
-                                          cd, REG_SP, (stackframesize + s1) * 4 + 4, var->regoff);
+                                          cd, REG_SP, (cd->stackframesize + s1) * 4 + 4, var->vv.regoff);
                                                                        /* + 4 for return address */
                                } 
                                else {                               /* stack arg -> spilled  */
@@ -277,15 +278,15 @@ bool codegen(jitdata *jd)
                                                /* no copy avoiding by now possible with SSA */
                                                if (ls != NULL) {
                                                        emit_mov_membase_reg(   /* + 4 for return address */
-                                                                cd, REG_SP, (stackframesize + s1) * 4 + 4,
+                                                                cd, REG_SP, (cd->stackframesize + s1) * 4 + 4,
                                                                 REG_ITMP1);    
                                                        emit_mov_reg_membase(
-                                                                cd, REG_ITMP1, REG_SP, var->regoff * 4);
+                                                                cd, REG_ITMP1, REG_SP, var->vv.regoff * 4);
                                                }
                                                else 
 #endif /*defined(ENABLE_SSA)*/
                                                                  /* reuse Stackslotand avoid copying */
-                                                       var->regoff = stackframesize + s1 + 1;
+                                                       var->vv.regoff = cd->stackframesize + s1 + 1;
 
                                        } 
                                        else {
@@ -293,20 +294,20 @@ bool codegen(jitdata *jd)
                                                /* no copy avoiding by now possible with SSA */
                                                if (ls != NULL) {
                                                        emit_mov_membase_reg(  /* + 4 for return address */
-                                                                cd, REG_SP, (stackframesize + s1) * 4 + 4,
+                                                                cd, REG_SP, (cd->stackframesize + s1) * 4 + 4,
                                                                 REG_ITMP1);
                                                        emit_mov_reg_membase(
-                                                                cd, REG_ITMP1, REG_SP, var->regoff * 4);
+                                                                cd, REG_ITMP1, REG_SP, var->vv.regoff * 4);
                                                        emit_mov_membase_reg(   /* + 4 for return address */
-                                                                 cd, REG_SP, (stackframesize + s1) * 4 + 4 + 4,
+                                                                 cd, REG_SP, (cd->stackframesize + s1) * 4 + 4 + 4,
                                                                  REG_ITMP1);             
                                                        emit_mov_reg_membase(
-                                                                cd, REG_ITMP1, REG_SP, var->regoff * 4 + 4);
+                                                                cd, REG_ITMP1, REG_SP, var->vv.regoff * 4 + 4);
                                                }
                                                else
 #endif /*defined(ENABLE_SSA)*/
                                                                  /* reuse Stackslotand avoid copying */
-                                                       var->regoff = stackframesize + s1 + 1;
+                                                       var->vv.regoff = cd->stackframesize + s1 + 1;
                                        }
                                }
                        }
@@ -316,9 +317,9 @@ bool codegen(jitdata *jd)
                                log_text("There are no float argument registers!");
                                assert(0);
                                if (!(var->flags & INMEMORY)) {  /* reg arg -> register   */
-                                       /* rd->argfltregs[md->params[p].regoff -> var->regoff     */
+                                       /* rd->argfltregs[md->params[p].regoff -> var->vv.regoff     */
                                } else {                                     /* reg arg -> spilled    */
-                                       /* rd->argfltregs[md->params[p].regoff -> var->regoff * 4 */
+                                       /* rd->argfltregs[md->params[p].regoff -> var->vv.regoff * 4 */
                                }
 
                        } 
@@ -326,16 +327,16 @@ bool codegen(jitdata *jd)
                                if (!(var->flags & INMEMORY)) {      /* stack-arg -> register */
                                        if (t == TYPE_FLT) {
                                                emit_flds_membase(
-                            cd, REG_SP, (stackframesize + s1) * 4 + 4);
+                            cd, REG_SP, (cd->stackframesize + s1) * 4 + 4);
                                                assert(0);
-/*                                             emit_fstp_reg(cd, var->regoff + fpu_st_offset); */
+/*                                             emit_fstp_reg(cd, var->vv.regoff + fpu_st_offset); */
 
                                        } 
                                        else {
                                                emit_fldl_membase(
-                            cd, REG_SP, (stackframesize + s1) * 4 + 4);
+                            cd, REG_SP, (cd->stackframesize + s1) * 4 + 4);
                                                assert(0);
-/*                                             emit_fstp_reg(cd, var->regoff + fpu_st_offset); */
+/*                                             emit_fstp_reg(cd, var->vv.regoff + fpu_st_offset); */
                                        }
 
                                } else {                             /* stack-arg -> spilled  */
@@ -343,24 +344,24 @@ bool codegen(jitdata *jd)
                                        /* no copy avoiding by now possible with SSA */
                                        if (ls != NULL) {
                                                emit_mov_membase_reg(
-                                                cd, REG_SP, (stackframesize + s1) * 4 + 4, REG_ITMP1);
+                                                cd, REG_SP, (cd->stackframesize + s1) * 4 + 4, REG_ITMP1);
                                                emit_mov_reg_membase(
-                                                                        cd, REG_ITMP1, REG_SP, var->regoff * 4);
+                                                                        cd, REG_ITMP1, REG_SP, var->vv.regoff * 4);
                                                if (t == TYPE_FLT) {
                                                        emit_flds_membase(
-                                                                 cd, REG_SP, (stackframesize + s1) * 4 + 4);
-                                                       emit_fstps_membase(cd, REG_SP, var->regoff * 4);
+                                                                 cd, REG_SP, (cd->stackframesize + s1) * 4 + 4);
+                                                       emit_fstps_membase(cd, REG_SP, var->vv.regoff * 4);
                                                } 
                                                else {
                                                        emit_fldl_membase(
-                                                                 cd, REG_SP, (stackframesize + s1) * 4 + 4);
-                                                       emit_fstpl_membase(cd, REG_SP, var->regoff * 4);
+                                                                 cd, REG_SP, (cd->stackframesize + s1) * 4 + 4);
+                                                       emit_fstpl_membase(cd, REG_SP, var->vv.regoff * 4);
                                                }
                                        }
                                        else
 #endif /*defined(ENABLE_SSA)*/
                                                                  /* reuse Stackslotand avoid copying */
-                                               var->regoff = stackframesize + s1 + 1;
+                                               var->vv.regoff = cd->stackframesize + s1 + 1;
                                }
                        }
                }
@@ -376,7 +377,7 @@ bool codegen(jitdata *jd)
                        M_MOV_IMM(&m->class->object.header, REG_ITMP1);
                }
                else {
-                       M_ALD(REG_ITMP1, REG_SP, stackframesize * 4 + 4);
+                       M_ALD(REG_ITMP1, REG_SP, cd->stackframesize * 4 + 4);
                        M_TEST(REG_ITMP1);
                        M_BEQ(0);
                        codegen_add_nullpointerexception_ref(cd);
@@ -389,123 +390,41 @@ bool codegen(jitdata *jd)
        }                       
 #endif
 
-       /* copy argument registers to stack and call trace function with pointer
-          to arguments on stack.
-       */
-
 #if !defined(NDEBUG)
-       if (opt_verbosecall) {
-               stack_off = 0;
-               s1 = INT_TMP_CNT * 4 + TRACE_ARGS_NUM * 8 + 4 + 4 + stackframesize * 4;
-
-               M_ISUB_IMM(INT_TMP_CNT * 4 + TRACE_ARGS_NUM * 8 + 4, REG_SP);
-
-               /* save temporary registers for leaf methods */
-
-               for (p = 0; p < INT_TMP_CNT; p++)
-                       M_IST(rd->tmpintregs[p], REG_SP, TRACE_ARGS_NUM * 8 + 4 + p * 4);
-
-               for (p = 0, l = 0; p < md->paramcount && p < TRACE_ARGS_NUM; p++) {
-                       t = md->paramtypes[p].type;
-
-                       if (IS_INT_LNG_TYPE(t)) {
-                               if (IS_2_WORD_TYPE(t)) {
-                                       emit_mov_membase_reg(cd, REG_SP, s1 + stack_off, REG_ITMP1);
-                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, p * 8);
-                                       emit_mov_membase_reg(cd, REG_SP, s1 + stack_off + 4, REG_ITMP1);
-                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, p * 8 + 4);
-
-                               } else if (t == TYPE_ADR) {
-/*                             } else { */
-                                       emit_mov_membase_reg(cd, REG_SP, s1 + stack_off, REG_ITMP1);
-                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, p * 8);
-                                       emit_alu_reg_reg(cd, ALU_XOR, REG_ITMP1, REG_ITMP1);
-                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, p * 8 + 4);
-
-                               } else {
-                                       emit_mov_membase_reg(cd, REG_SP, s1 + stack_off, EAX);
-                                       emit_cltd(cd);
-                                       emit_mov_reg_membase(cd, EAX, REG_SP, p * 8);
-                                       emit_mov_reg_membase(cd, EDX, REG_SP, p * 8 + 4);
-                               }
-
-                       } else {
-                               if (!IS_2_WORD_TYPE(t)) {
-                                       emit_flds_membase(cd, REG_SP, s1 + stack_off);
-                                       emit_fstps_membase(cd, REG_SP, p * 8);
-                                       emit_alu_reg_reg(cd, ALU_XOR, REG_ITMP1, REG_ITMP1);
-                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, p * 8 + 4);
-
-                               } else {
-                                       emit_fldl_membase(cd, REG_SP, s1 + stack_off);
-                                       emit_fstpl_membase(cd, REG_SP, p * 8);
-                               }
-                       }
-                       stack_off += (IS_2_WORD_TYPE(t)) ? 8 : 4;
-               }
-
-               /* fill up the remaining arguments */
-               emit_alu_reg_reg(cd, ALU_XOR, REG_ITMP1, REG_ITMP1);
-               for (p = md->paramcount; p < TRACE_ARGS_NUM; p++) {
-                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, p * 8);
-                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, p * 8 + 4);
-               }
-
-               emit_mov_imm_membase(cd, (ptrint) m, REG_SP, TRACE_ARGS_NUM * 8);
-               emit_mov_imm_reg(cd, (ptrint) builtin_trace_args, REG_ITMP1);
-               emit_call_reg(cd, REG_ITMP1);
-
-               /* restore temporary registers for leaf methods */
-
-               for (p = 0; p < INT_TMP_CNT; p++)
-                       M_ILD(rd->tmpintregs[p], REG_SP, TRACE_ARGS_NUM * 8 + 4 + p * 4);
-
-               M_IADD_IMM(INT_TMP_CNT * 4 + TRACE_ARGS_NUM * 8 + 4, REG_SP);
-       }
-#endif /* !defined(NDEBUG) */
+       emit_verbosecall_enter(jd);
+#endif
 
        } 
 
 #if defined(ENABLE_SSA)
        /* with SSA Header is Basic Block 0 - insert phi Moves if necessary */
        if ( ls != NULL)
-                       codegen_insert_phi_moves(cd, rd, ls, ls->basicblocks[0]);
+               codegen_insert_phi_moves(jd, ls->basicblocks[0]);
 #endif
 
        /* end of header generation */
 
-       replacementpoint = jd->code->rplpoints;
+       /* create replacement points */
+
+       REPLACEMENT_POINTS_INIT(cd, jd);
 
        /* walk through all basic blocks */
-       for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next) {
+
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
 
                bptr->mpc = (s4) (cd->mcodeptr - cd->mcodebase);
 
                if (bptr->flags >= BBREACHED) {
-
                /* branch resolving */
 
-               branchref *brefs;
-               for (brefs = bptr->branchrefs; brefs != NULL; brefs = brefs->next) {
-                       gen_resolvebranch(cd->mcodebase + brefs->branchpos, 
-                                         brefs->branchpos,
-                                                         bptr->mpc);
-               }
+               codegen_resolve_branchrefs(cd, bptr);
 
                /* handle replacement points */
 
-               if (bptr->bitflags & BBFLAG_REPLACEMENT) {
-                       replacementpoint->pc = (u1*)bptr->mpc; /* will be resolved later */
-                       
-                       replacementpoint++;
-
-                       assert(cd->lastmcodeptr <= cd->mcodeptr);
-                       cd->lastmcodeptr = cd->mcodeptr + 5; /* 5 byte jmp patch */
-               }
+               REPLACEMENT_POINT_BLOCK_START(cd, bptr);
 
                /* copy interface registers to their destination */
 
-               src = bptr->instack;
                len = bptr->indepth;
                MCODECHECK(512);
 
@@ -528,106 +447,59 @@ bool codegen(jitdata *jd)
                if (ls != NULL) {
                        last_cmd_was_goto = false;
 # endif
-                       if (src != NULL) {
+                       if (len > 0) {
                                len--;
+                               var = VAR(bptr->invars[len]);
                                if (bptr->type != BBTYPE_STD) {
-                                       if (!IS_2_WORD_TYPE(src->type)) {
-                                               if (bptr->type == BBTYPE_SBR) {
-                                                       if (!(src->flags & INMEMORY))
-                                                               d = src->regoff;
-                                                       else
-                                                               d = REG_ITMP1;
-                                                       emit_pop_reg(cd, d);
-                                                       emit_store(jd, NULL, src, d);
-                                               } else if (bptr->type == BBTYPE_EXH) {
-                                                       if (!(src->flags & INMEMORY))
-                                                               d = src->regoff;
-                                                       else
-                                                               d = REG_ITMP1;
+                                       if (!IS_2_WORD_TYPE(var->type)) {
+                                               if (bptr->type == BBTYPE_EXH) {
+                                                       d = codegen_reg_of_var(0, var, REG_ITMP1);
                                                        M_INTMOVE(REG_ITMP1, d);
-                                                       emit_store(jd, NULL, src, d);
+                                                       emit_store(jd, NULL, var, d);
                                                }
-
-                                       } else {
-                                               log_text("copy interface registers(EXH, SBR): longs have to be in memory (begin 1)");
+                                       } 
+                                       else {
+                                               log_text("copy interface registers(EXH, SBR): longs \
+                                  have to be in memory (begin 1)");
                                                assert(0);
                                        }
                                }
-                               src = src->prev;
                        }
 
-               } else
+               } 
+               else
 #endif /* defined(ENABLE_LSRA) || defined(ENABLE_SSA) */
                {
-               while (src != NULL) {
+               while (len) {
                        len--;
+                       var = VAR(bptr->invars[len]);
                        if ((len == bptr->indepth-1) && (bptr->type != BBTYPE_STD)) {
-                               if (!IS_2_WORD_TYPE(src->type)) {
-                                       if (bptr->type == BBTYPE_SBR) {
-                                               d = codegen_reg_of_var(rd, 0, src, REG_ITMP1);
-                                               emit_pop_reg(cd, d);
-                                               emit_store(jd, NULL, src, d);
-
-                                       } else if (bptr->type == BBTYPE_EXH) {
-                                               d = codegen_reg_of_var(rd, 0, src, REG_ITMP1);
+                               if (!IS_2_WORD_TYPE(var->type)) {
+                                       if (bptr->type == BBTYPE_EXH) {
+                                               d = codegen_reg_of_var(0, var, REG_ITMP1);
                                                M_INTMOVE(REG_ITMP1, d);
-                                               emit_store(jd, NULL, src, d);
+                                               emit_store(jd, NULL, var, d);
                                        }
-                               } else {
-                                       log_text("copy interface registers: longs have to be in memory (begin 1)");
+                               } 
+                               else {
+                                       log_text("copy interface registers: longs have to be in \
+                               memory (begin 1)");
                                        assert(0);
                                }
 
-                       } else {
-                               if (IS_LNG_TYPE(src->type))
-                                       d = codegen_reg_of_var(rd, 0, src, PACK_REGS(REG_ITMP1, REG_ITMP2));
-                               else
-                                       d = codegen_reg_of_var(rd, 0, src, REG_ITMP1);
-/*                                     d = codegen_reg_of_var(rd, 0, src, REG_IFTMP); */
-
-                               if ((src->varkind != STACKVAR)) {
-                                       s2 = src->type;
-                                       s1 = rd->interfaces[len][s2].regoff;
-
-                                       if (IS_FLT_DBL_TYPE(s2)) {
-                                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
-                                                       M_FLTMOVE(s1, d);
-
-                                               } else {
-                                                       if (IS_2_WORD_TYPE(s2))
-                                                               M_DLD(d, REG_SP, s1 * 4);
-                                                       else
-                                                               M_FLD(d, REG_SP, s1 * 4);
-                                               }
-
-                                       } else {
-                                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
-                                                       if (IS_2_WORD_TYPE(s2))
-                                                               M_LNGMOVE(s1, d);
-                                                       else
-                                                               M_INTMOVE(s1, d);
-
-                                               } else {
-                                                       if (IS_2_WORD_TYPE(s2))
-                                                               M_LLD(d, REG_SP, s1 * 4);
-                                                       else
-                                                               M_ILD(d, REG_SP, s1 * 4);
-                                               }
-                                       }
-
-                                       emit_store(jd, NULL, src, d);
-                               }
+                       } 
+                       else {
+                               assert((var->flags & INOUT));
                        }
-                       src = src->prev;
-               }
-               }
+               } /* while (len) */
+               } /* */
 
                /* walk through all instructions */
                
-               src = bptr->instack;
                len = bptr->icount;
                currentline = 0;
-               for (iptr = bptr->iinstr; len > 0; src = iptr->dst, len--, iptr++) {
+
+               for (iptr = bptr->iinstr; len > 0; len--, iptr++) {
                        if (iptr->line != currentline) {
                                dseg_addlinenumber(cd, iptr->line);
                                currentline = iptr->line;
@@ -636,164 +508,114 @@ bool codegen(jitdata *jd)
                        MCODECHECK(1024);                         /* 1kB should be enough */
 
                switch (iptr->opc) {
-               case ICMD_INLINE_START:
-                       {
-                               insinfo_inline *insinfo = (insinfo_inline *) iptr->target;
-#if defined(ENABLE_THREADS)
-                               if (insinfo->synchronize) {
-                                       /* add monitor enter code */
-                                       if (insinfo->method->flags & ACC_STATIC) {
-                                               M_MOV_IMM(&insinfo->method->class->object.header, REG_ITMP1);
-                                               M_AST(REG_ITMP1, REG_SP, 0 * 4);
-                                       } 
-                                       else {
-                                               /* nullpointer check must have been performed before */
-                                               /* (XXX not done, yet) */
-                                               var = &(rd->locals[insinfo->synclocal][TYPE_ADR]);
-                                               if (var->flags & INMEMORY) {
-                                                       emit_mov_membase_reg(cd, REG_SP, var->regoff * 4, REG_ITMP1);
-                                                       M_AST(REG_ITMP1, REG_SP, 0 * 4);
-                                               } 
-                                               else {
-                                                       M_AST(var->regoff, REG_SP, 0 * 4);
-                                               }
-                                       }
-
-                                       M_MOV_IMM(LOCK_monitor_enter, REG_ITMP3);
-                                       M_CALL(REG_ITMP3);
-                               }
-#endif
-                               dseg_addlinenumber_inline_start(cd, iptr);
-                       }
+               case ICMD_NOP:        /* ...  ==> ...                                 */
+               case ICMD_POP:        /* ..., value  ==> ...                          */
+               case ICMD_POP2:       /* ..., value, value  ==> ...                   */
                        break;
 
-               case ICMD_INLINE_END:
-                       {
-                               insinfo_inline *insinfo = (insinfo_inline *) iptr->target;
+               case ICMD_INLINE_START:
 
-                               dseg_addlinenumber_inline_end(cd, iptr);
-                               dseg_addlinenumber(cd, iptr->line);
+                       REPLACEMENT_POINT_INLINE_START(cd, iptr);
+                       break;
 
-#if defined(ENABLE_THREADS)
-                               if (insinfo->synchronize) {
-                                       /* add monitor exit code */
-                                       if (insinfo->method->flags & ACC_STATIC) {
-                                               M_MOV_IMM(&insinfo->method->class->object.header, REG_ITMP1);
-                                               M_AST(REG_ITMP1, REG_SP, 0 * 4);
-                                       } 
-                                       else {
-                                               var = &(rd->locals[insinfo->synclocal][TYPE_ADR]);
-                                               if (var->flags & INMEMORY) {
-                                                       M_ALD(REG_ITMP1, REG_SP, var->regoff * 4);
-                                                       M_AST(REG_ITMP1, REG_SP, 0 * 4);
-                                               } 
-                                               else {
-                                                       M_AST(var->regoff, REG_SP, 0 * 4);
-                                               }
-                                       }
+               case ICMD_INLINE_BODY:
 
-                                       M_MOV_IMM(LOCK_monitor_exit, REG_ITMP3);
-                                       M_CALL(REG_ITMP3);
-                               }
-#endif
-                       }
+                       REPLACEMENT_POINT_INLINE_BODY(cd, iptr);
+                       dseg_addlinenumber_inline_start(cd, iptr);
+                       dseg_addlinenumber(cd, iptr->line);
                        break;
 
-               case ICMD_NOP:        /* ...  ==> ...                                 */
+               case ICMD_INLINE_END:
+
+                       dseg_addlinenumber_inline_end(cd, iptr);
+                       dseg_addlinenumber(cd, iptr->line);
                        break;
 
                case ICMD_CHECKNULL:  /* ..., objectref  ==> ..., objectref           */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       M_TEST(s1);
-                       M_BEQ(0);
-                       codegen_add_nullpointerexception_ref(cd);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       emit_nullpointer_check(cd, iptr, s1);
                        break;
 
                /* constant operations ************************************************/
 
                case ICMD_ICONST:     /* ...  ==> ..., constant                       */
-                                     /* op1 = 0, val.i = constant                    */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
-                       ICONST(d, iptr->val.i);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       ICONST(d, iptr->sx.val.i);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LCONST:     /* ...  ==> ..., constant                       */
-                                     /* op1 = 0, val.l = constant                    */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
-                       LCONST(d, iptr->val.l);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
+                       LCONST(d, iptr->sx.val.l);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_FCONST:     /* ...  ==> ..., constant                       */
-                                     /* op1 = 0, val.f = constant                    */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
-                       if (iptr->val.f == 0.0) {
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                       if (iptr->sx.val.f == 0.0) {
                                emit_fldz(cd);
 
                                /* -0.0 */
-                               if (iptr->val.i == 0x80000000) {
+                               if (iptr->sx.val.i == 0x80000000) {
                                        emit_fchs(cd);
                                }
 
-                       } else if (iptr->val.f == 1.0) {
+                       } else if (iptr->sx.val.f == 1.0) {
                                emit_fld1(cd);
 
-                       } else if (iptr->val.f == 2.0) {
+                       } else if (iptr->sx.val.f == 2.0) {
                                emit_fld1(cd);
                                emit_fld1(cd);
                                emit_faddp(cd);
 
                        } else {
-                               disp = dseg_addfloat(cd, iptr->val.f);
+                               disp = dseg_add_float(cd, iptr->sx.val.f);
                                emit_mov_imm_reg(cd, 0, REG_ITMP1);
                                dseg_adddata(cd);
                                emit_flds_membase(cd, REG_ITMP1, disp);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
                
                case ICMD_DCONST:     /* ...  ==> ..., constant                       */
-                                     /* op1 = 0, val.d = constant                    */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
-                       if (iptr->val.d == 0.0) {
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                       if (iptr->sx.val.d == 0.0) {
                                emit_fldz(cd);
 
                                /* -0.0 */
-                               if (iptr->val.l == 0x8000000000000000LL) {
+                               if (iptr->sx.val.l == 0x8000000000000000LL) {
                                        emit_fchs(cd);
                                }
 
-                       } else if (iptr->val.d == 1.0) {
+                       } else if (iptr->sx.val.d == 1.0) {
                                emit_fld1(cd);
 
-                       } else if (iptr->val.d == 2.0) {
+                       } else if (iptr->sx.val.d == 2.0) {
                                emit_fld1(cd);
                                emit_fld1(cd);
                                emit_faddp(cd);
 
                        } else {
-                               disp = dseg_adddouble(cd, iptr->val.d);
+                               disp = dseg_add_double(cd, iptr->sx.val.d);
                                emit_mov_imm_reg(cd, 0, REG_ITMP1);
                                dseg_adddata(cd);
                                emit_fldl_membase(cd, REG_ITMP1, disp);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_ACONST:     /* ...  ==> ..., constant                       */
-                                     /* op1 = 0, val.a = constant                    */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                codegen_addpatchref(cd, PATCHER_aconst,
-                                                                       ICMD_ACONST_UNRESOLVED_CLASSREF(iptr), 0);
+                                                                       iptr->sx.val.c.ref, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -802,221 +624,35 @@ bool codegen(jitdata *jd)
                                M_MOV_IMM(NULL, d);
 
                        } else {
-                               if (iptr->val.a == NULL)
+                               if (iptr->sx.val.anyptr == NULL)
                                        M_CLR(d);
                                else
-                                       M_MOV_IMM(iptr->val.a, d);
-                       }
-                       emit_store(jd, iptr, iptr->dst, d);
-                       break;
-
-
-               /* load/store operations **********************************************/
-
-               case ICMD_ILOAD:      /* ...  ==> ..., content of local variable      */
-               case ICMD_ALOAD:      /* op1 = local variable                         */
-
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
-                       if ((iptr->dst->varkind == LOCALVAR) &&
-                           (iptr->dst->varnum == iptr->op1))
-                               break;
-                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
-                       if (var->flags & INMEMORY)
-                               M_ILD(d, REG_SP, var->regoff * 4);
-                       else
-                               M_INTMOVE(var->regoff, d);
-                       emit_store(jd, iptr, iptr->dst, d);
-                       break;
-
-               case ICMD_LLOAD:      /* ...  ==> ..., content of local variable      */
-                                     /* op1 = local variable                         */
-  
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
-                       if ((iptr->dst->varkind == LOCALVAR) &&
-                           (iptr->dst->varnum == iptr->op1))
-                               break;
-                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
-                       if (var->flags & INMEMORY)
-                               M_LLD(d, REG_SP, var->regoff * 4);
-                       else
-                               M_LNGMOVE(var->regoff, d);
-                       emit_store(jd, iptr, iptr->dst, d);
-                       break;
-
-               case ICMD_FLOAD:      /* ...  ==> ..., content of local variable      */
-                                     /* op1 = local variable                         */
-
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
-                       if ((iptr->dst->varkind == LOCALVAR) &&
-                           (iptr->dst->varnum == iptr->op1))
-                               break;
-                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
-                       if (var->flags & INMEMORY)
-                               M_FLD(d, REG_SP, var->regoff * 4);
-                       else
-                               M_FLTMOVE(var->regoff, d);
-                       emit_store(jd, iptr, iptr->dst, d);
-                       break;
-
-               case ICMD_DLOAD:      /* ...  ==> ..., content of local variable      */
-                                     /* op1 = local variable                         */
-
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
-                       if ((iptr->dst->varkind == LOCALVAR) &&
-                           (iptr->dst->varnum == iptr->op1))
-                               break;
-                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
-                       if (var->flags & INMEMORY)
-                               M_DLD(d, REG_SP, var->regoff * 4);
-                       else
-                               M_FLTMOVE(var->regoff, d);
-                       emit_store(jd, iptr, iptr->dst, d);
-                       break;
-
-               case ICMD_ISTORE:     /* ..., value  ==> ...                          */
-               case ICMD_ASTORE:     /* op1 = local variable                         */
-
-                       if ((src->varkind == LOCALVAR) &&
-                           (src->varnum == iptr->op1))
-                               break;
-                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
-                       if (var->flags & INMEMORY) {
-                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                               M_IST(s1, REG_SP, var->regoff * 4);     
-                       }
-                       else {
-                               s1 = emit_load_s1(jd, iptr, src, var->regoff);
-                               M_INTMOVE(s1, var->regoff);
+                                       M_MOV_IMM(iptr->sx.val.anyptr, d);
                        }
+                       emit_store_dst(jd, iptr, d);
                        break;
 
-               case ICMD_LSTORE:     /* ..., value  ==> ...                          */
-                                     /* op1 = local variable                         */
 
-                       if ((src->varkind == LOCALVAR) &&
-                           (src->varnum == iptr->op1))
-                               break;
-                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
-                       if (var->flags & INMEMORY) {
-                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                               M_LST(s1, REG_SP, var->regoff * 4);
-                       }
-                       else {
-                               s1 = emit_load_s1(jd, iptr, src, var->regoff);
-                               M_LNGMOVE(s1, var->regoff);
-                       }
-                       break;
-
-               case ICMD_FSTORE:     /* ..., value  ==> ...                          */
-                                     /* op1 = local variable                         */
-
-                       if ((src->varkind == LOCALVAR) &&
-                           (src->varnum == iptr->op1))
-                               break;
-                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
-                       if (var->flags & INMEMORY) {
-                               s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                               M_FST(s1, REG_SP, var->regoff * 4);
-                       }
-                       else {
-                               s1 = emit_load_s1(jd, iptr, src, var->regoff);
-                               M_FLTMOVE(s1, var->regoff);
-                       }
-                       break;
-
-               case ICMD_DSTORE:     /* ..., value  ==> ...                          */
-                                     /* op1 = local variable                         */
-
-                       if ((src->varkind == LOCALVAR) &&
-                           (src->varnum == iptr->op1))
-                               break;
-                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
-                       if (var->flags & INMEMORY) {
-                               s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                               M_DST(s1, REG_SP, var->regoff * 4);
-                       }
-                       else {
-                               s1 = emit_load_s1(jd, iptr, src, var->regoff);
-                               M_FLTMOVE(s1, var->regoff);
-                       }
-                       break;
-
-
-               /* pop/dup/swap operations ********************************************/
-
-               /* attention: double and longs are only one entry in CACAO ICMDs      */
-
-               case ICMD_POP:        /* ..., value  ==> ...                          */
-               case ICMD_POP2:       /* ..., value, value  ==> ...                   */
-                       break;
-
-               case ICMD_DUP:        /* ..., a ==> ..., a, a                         */
-
-                       M_COPY(src, iptr->dst);
-                       break;
+               /* load/store/copy/move operations ************************************/
 
-               case ICMD_DUP2:       /* ..., a, b ==> ..., a, b, a, b                */
+               case ICMD_ILOAD:
+               case ICMD_ALOAD:
+               case ICMD_LLOAD:
+               case ICMD_FLOAD:
+               case ICMD_DLOAD:
+               case ICMD_ISTORE:
+               case ICMD_LSTORE:
+               case ICMD_FSTORE:
+               case ICMD_DSTORE:
+               case ICMD_COPY:
+               case ICMD_MOVE:
 
-                       M_COPY(src,       iptr->dst);
-                       M_COPY(src->prev, iptr->dst->prev);
+                       emit_copy(jd, iptr, VAROP(iptr->s1), VAROP(iptr->dst));
                        break;
 
-               case ICMD_DUP_X1:     /* ..., a, b ==> ..., b, a, b                   */
-
-                       M_COPY(src,       iptr->dst);
-                       M_COPY(src->prev, iptr->dst->prev);
-#if defined(ENABLE_SSA)
-                       if ((ls==NULL) || (iptr->dst->varkind != TEMPVAR) ||
-                               (ls->lifetime[-iptr->dst->varnum-1].type != -1)) {
-#endif
-                               M_COPY(iptr->dst, iptr->dst->prev->prev);
-#if defined(ENABLE_SSA)
-                       } else {
-                               M_COPY(src, iptr->dst->prev->prev);
-                       }
-#endif
-                       break;
-
-               case ICMD_DUP_X2:     /* ..., a, b, c ==> ..., c, a, b, c             */
-
-                       M_COPY(src,             iptr->dst);
-                       M_COPY(src->prev,       iptr->dst->prev);
-                       M_COPY(src->prev->prev, iptr->dst->prev->prev);
-#if defined(ENABLE_SSA)
-                       if ((ls==NULL) || (iptr->dst->varkind != TEMPVAR) ||
-                               (ls->lifetime[-iptr->dst->varnum-1].type != -1)) {
-#endif
-                               M_COPY(iptr->dst,       iptr->dst->prev->prev->prev);
-#if defined(ENABLE_SSA)
-                       } else {
-                               M_COPY(src, iptr->dst->prev->prev->prev);
-                       }
-#endif
-                       break;
-
-               case ICMD_DUP2_X1:    /* ..., a, b, c ==> ..., b, c, a, b, c          */
-
-                       M_COPY(src,             iptr->dst);
-                       M_COPY(src->prev,       iptr->dst->prev);
-                       M_COPY(src->prev->prev, iptr->dst->prev->prev);
-                       M_COPY(iptr->dst,       iptr->dst->prev->prev->prev);
-                       M_COPY(iptr->dst->prev, iptr->dst->prev->prev->prev->prev);
-                       break;
-
-               case ICMD_DUP2_X2:    /* ..., a, b, c, d ==> ..., c, d, a, b, c, d    */
-
-                       M_COPY(src,                   iptr->dst);
-                       M_COPY(src->prev,             iptr->dst->prev);
-                       M_COPY(src->prev->prev,       iptr->dst->prev->prev);
-                       M_COPY(src->prev->prev->prev, iptr->dst->prev->prev->prev);
-                       M_COPY(iptr->dst,             iptr->dst->prev->prev->prev->prev);
-                       M_COPY(iptr->dst->prev,       iptr->dst->prev->prev->prev->prev->prev);
-                       break;
-
-               case ICMD_SWAP:       /* ..., a, b ==> ..., b, a                      */
-
-                       M_COPY(src,       iptr->dst->prev);
-                       M_COPY(src->prev, iptr->dst);
+               case ICMD_ASTORE:
+                       if (!(iptr->flags.bits & INS_FLAG_RETADDR))
+                               emit_copy(jd, iptr, VAROP(iptr->s1), VAROP(iptr->dst));
                        break;
 
 
@@ -1024,124 +660,130 @@ bool codegen(jitdata *jd)
 
                case ICMD_INEG:       /* ..., value  ==> ..., - value                 */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1); 
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
                        M_NEG(d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LNEG:       /* ..., value  ==> ..., - value                 */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_LNGMOVE(s1, d);
                        M_NEG(GET_LOW_REG(d));
                        M_IADDC_IMM(0, GET_HIGH_REG(d));
                        M_NEG(GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_I2L:        /* ..., value  ==> ..., value                   */
 
-                       s1 = emit_load_s1(jd, iptr, src, EAX);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, EAX_EDX_PACKED);
+                       s1 = emit_load_s1(jd, iptr, EAX);
+                       d = codegen_reg_of_dst(jd, iptr, EAX_EDX_PACKED);
                        M_INTMOVE(s1, EAX);
                        M_CLTD;
                        M_LNGMOVE(EAX_EDX_PACKED, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_L2I:        /* ..., value  ==> ..., value                   */
 
-                       s1 = emit_load_s1_low(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        M_INTMOVE(s1, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_INT2BYTE:   /* ..., value  ==> ..., value                   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
                        M_SLL_IMM(24, d);
                        M_SRA_IMM(24, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_INT2CHAR:   /* ..., value  ==> ..., value                   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        M_CZEXT(s1, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_INT2SHORT:  /* ..., value  ==> ..., value                   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        M_SSEXT(s1, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
 
                case ICMD_IADD:       /* ..., val1, val2  ==> ..., val1 + val2        */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s2 == d)
                                M_IADD(s1, d);
                        else {
                                M_INTMOVE(s1, d);
                                M_IADD(s2, d);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
+               case ICMD_IINC:
                case ICMD_IADDCONST:  /* ..., value  ==> ..., value + constant        */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
+
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                               
+                       /* `inc reg' is slower on p4's (regarding to ia32
+                          optimization reference manual and benchmarks) and as
+                          fast on athlon's. */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
                        M_INTMOVE(s1, d);
-                       M_IADD_IMM(iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_IADD_IMM(iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LADD:       /* ..., val1, val2  ==> ..., val1 + val2        */
 
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_INTMOVE(s1, GET_LOW_REG(d));
                        M_IADD(s2, GET_LOW_REG(d));
                        /* don't use REG_ITMP1 */
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP2);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP3);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        M_INTMOVE(s1, GET_HIGH_REG(d));
                        M_IADDC(s2, GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LADDCONST:  /* ..., value  ==> ..., value + constant        */
-                                     /* val.l = constant                             */
+                                     /* sx.val.l = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_LNGMOVE(s1, d);
-                       M_IADD_IMM(iptr->val.l, GET_LOW_REG(d));
-                       M_IADDC_IMM(iptr->val.l >> 32, GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_IADD_IMM(iptr->sx.val.l, GET_LOW_REG(d));
+                       M_IADDC_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(d));
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_ISUB:       /* ..., val1, val2  ==> ..., val1 - val2        */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        if (s2 == d) {
                                M_INTMOVE(s1, REG_ITMP1);
                                M_ISUB(s2, REG_ITMP1);
@@ -1151,24 +793,24 @@ bool codegen(jitdata *jd)
                                M_INTMOVE(s1, d);
                                M_ISUB(s2, d);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_ISUBCONST:  /* ..., value  ==> ..., value + constant        */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                             */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
-                       M_ISUB_IMM(iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_ISUB_IMM(iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LSUB:       /* ..., val1, val2  ==> ..., val1 - val2        */
 
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        if (s2 == GET_LOW_REG(d)) {
                                M_INTMOVE(s1, REG_ITMP1);
                                M_ISUB(s2, REG_ITMP1);
@@ -1179,8 +821,8 @@ bool codegen(jitdata *jd)
                                M_ISUB(s2, GET_LOW_REG(d));
                        }
                        /* don't use REG_ITMP1 */
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP2);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP3);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        if (s2 == GET_HIGH_REG(d)) {
                                M_INTMOVE(s1, REG_ITMP2);
                                M_ISUBB(s2, REG_ITMP2);
@@ -1190,95 +832,90 @@ bool codegen(jitdata *jd)
                                M_INTMOVE(s1, GET_HIGH_REG(d));
                                M_ISUBB(s2, GET_HIGH_REG(d));
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LSUBCONST:  /* ..., value  ==> ..., value - constant        */
-                                     /* val.l = constant                             */
+                                     /* sx.val.l = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_LNGMOVE(s1, d);
-                       M_ISUB_IMM(iptr->val.l, GET_LOW_REG(d));
-                       M_ISUBB_IMM(iptr->val.l >> 32, GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_ISUB_IMM(iptr->sx.val.l, GET_LOW_REG(d));
+                       M_ISUBB_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(d));
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IMUL:       /* ..., val1, val2  ==> ..., val1 * val2        */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s2 == d)
                                M_IMUL(s1, d);
                        else {
                                M_INTMOVE(s1, d);
                                M_IMUL(s2, d);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IMULCONST:  /* ..., value  ==> ..., value * constant        */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
-                       M_IMUL_IMM(s1, iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
+                       M_IMUL_IMM(s1, iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LMUL:       /* ..., val1, val2  ==> ..., val1 * val2        */
 
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP2);
-                       s2 = emit_load_s2_low(jd, iptr, src, EDX);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, EAX_EDX_PACKED);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2_low(jd, iptr, EDX);
+                       d = codegen_reg_of_dst(jd, iptr, EAX_EDX_PACKED);
 
                        M_INTMOVE(s1, REG_ITMP2);
                        M_IMUL(s2, REG_ITMP2);
 
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, EAX);
-                       s2 = emit_load_s2_high(jd, iptr, src, EDX);
+                       s1 = emit_load_s1_low(jd, iptr, EAX);
+                       s2 = emit_load_s2_high(jd, iptr, EDX);
                        M_INTMOVE(s2, EDX);
                        M_IMUL(s1, EDX);
                        M_IADD(EDX, REG_ITMP2);
 
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, EAX);
-                       s2 = emit_load_s2_low(jd, iptr, src, EDX);
+                       s1 = emit_load_s1_low(jd, iptr, EAX);
+                       s2 = emit_load_s2_low(jd, iptr, EDX);
                        M_INTMOVE(s1, EAX);
                        M_MUL(s2);
                        M_INTMOVE(EAX, GET_LOW_REG(d));
                        M_IADD(REG_ITMP2, GET_HIGH_REG(d));
 
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LMULCONST:  /* ..., value  ==> ..., value * constant        */
-                                     /* val.l = constant                             */
+                                     /* sx.val.l = constant                          */
 
-                       s1 = emit_load_s1_low(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, EAX_EDX_PACKED);
-                       ICONST(EAX, iptr->val.l);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, EAX_EDX_PACKED);
+                       ICONST(EAX, iptr->sx.val.l);
                        M_MUL(s1);
-                       M_IMUL_IMM(s1, iptr->val.l >> 32, REG_ITMP2);
+                       M_IMUL_IMM(s1, iptr->sx.val.l >> 32, REG_ITMP2);
                        M_IADD(REG_ITMP2, EDX);
-                       s1 = emit_load_s1_high(jd, iptr, src, REG_ITMP2);
-                       M_IMUL_IMM(s1, iptr->val.l, REG_ITMP2);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       M_IMUL_IMM(s1, iptr->sx.val.l, REG_ITMP2);
                        M_IADD(REG_ITMP2, EDX);
                        M_LNGMOVE(EAX_EDX_PACKED, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, EAX);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, EAX);
-
-                       if (checknull) {
-                               M_TEST(s2);
-                               M_BEQ(0);
-                               codegen_add_arithmeticexception_ref(cd);
-                       }
+                       s1 = emit_load_s1(jd, iptr, EAX);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, EAX);
+                       emit_arithmetic_check(cd, iptr, s2);
 
                        M_INTMOVE(s1, EAX);           /* we need the first operand in EAX */
 
@@ -1292,20 +929,15 @@ bool codegen(jitdata *jd)
                        M_IDIV(s2);
 
                        M_INTMOVE(EAX, d);           /* if INMEMORY then d is already EAX */
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IREM:       /* ..., val1, val2  ==> ..., val1 % val2        */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, EAX);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, EDX);
-
-                       if (checknull) {
-                               M_TEST(s2);
-                               M_BEQ(0);
-                               codegen_add_arithmeticexception_ref(cd);
-                       }
+                       s1 = emit_load_s1(jd, iptr, EAX);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, EDX);
+                       emit_arithmetic_check(cd, iptr, s2);
 
                        M_INTMOVE(s1, EAX);           /* we need the first operand in EAX */
 
@@ -1320,94 +952,94 @@ bool codegen(jitdata *jd)
                        M_IDIV(s2);
 
                        M_INTMOVE(EDX, d);           /* if INMEMORY then d is already EDX */
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IDIVPOW2:   /* ..., value  ==> ..., value >> constant       */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
                        /* TODO: optimize for `/ 2' */
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
                        M_TEST(d);
                        M_BNS(6);
-                       M_IADD_IMM32((1 << iptr->val.i) - 1, d);  /* 32-bit for jump off. */
-                       M_SRA_IMM(iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_IADD_IMM32((1 << iptr->sx.val.i) - 1, d);/* 32-bit for jump off */
+                       M_SRA_IMM(iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IREMPOW2:   /* ..., value  ==> ..., value % constant        */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s1 == d) {
                                M_MOV(s1, REG_ITMP1);
                                s1 = REG_ITMP1;
                        } 
                        M_INTMOVE(s1, d);
-                       M_AND_IMM(iptr->val.i, d);
+                       M_AND_IMM(iptr->sx.val.i, d);
                        M_TEST(s1);
                        M_BGE(2 + 2 + 6 + 2);
                        M_MOV(s1, d);  /* don't use M_INTMOVE, so we know the jump offset */
                        M_NEG(d);
-                       M_AND_IMM32(iptr->val.i, d);        /* use 32-bit for jump offset */
+                       M_AND_IMM32(iptr->sx.val.i, d);     /* use 32-bit for jump offset */
                        M_NEG(d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
                case ICMD_LREM:       /* ..., val1, val2  ==> ..., val1 % val2        */
 
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT_PACKED);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_RESULT_PACKED);
 
                        M_INTMOVE(GET_LOW_REG(s2), REG_ITMP3);
                        M_OR(GET_HIGH_REG(s2), REG_ITMP3);
-                       M_BEQ(0);
-                       codegen_add_arithmeticexception_ref(cd);
+                       /* XXX could be optimized */
+                       emit_arithmetic_check(cd, iptr, REG_ITMP3);
 
-                       bte = iptr->val.a;
+                       bte = iptr->sx.s23.s3.bte;
                        md = bte->md;
 
                        M_LST(s2, REG_SP, 2 * 4);
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
                        M_LST(s1, REG_SP, 0 * 4);
 
                        M_MOV_IMM(bte->fp, REG_ITMP3);
                        M_CALL(REG_ITMP3);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LDIVPOW2:   /* ..., value  ==> ..., value >> constant       */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_RESULT_PACKED);
                        M_LNGMOVE(s1, d);
                        M_TEST(GET_HIGH_REG(d));
                        M_BNS(6 + 3);
-                       M_IADD_IMM32((1 << iptr->val.i) - 1, GET_LOW_REG(d));
+                       M_IADD_IMM32((1 << iptr->sx.val.i) - 1, GET_LOW_REG(d));
                        M_IADDC_IMM(0, GET_HIGH_REG(d));
-                       M_SRLD_IMM(iptr->val.i, GET_HIGH_REG(d), GET_LOW_REG(d));
-                       M_SRA_IMM(iptr->val.i, GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_SRLD_IMM(iptr->sx.val.i, GET_HIGH_REG(d), GET_LOW_REG(d));
+                       M_SRA_IMM(iptr->sx.val.i, GET_HIGH_REG(d));
+                       emit_store_dst(jd, iptr, d);
                        break;
 
 #if 0
                case ICMD_LREMPOW2:   /* ..., value  ==> ..., value % constant        */
-                                     /* val.l = constant                             */
+                                     /* sx.val.l = constant                          */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL);
-                       if (iptr->dst->flags & INMEMORY) {
-                               if (src->flags & INMEMORY) {
+                       d = codegen_reg_of_dst(jd, iptr, REG_NULL);
+                       if (iptr->dst.var->flags & INMEMORY) {
+                               if (iptr->s1.var->flags & INMEMORY) {
                                        /* Alpha algorithm */
                                        disp = 3;
-                                       CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4);
+                                       CALCOFFSETBYTES(disp, REG_SP, iptr->s1.var->vv.regoff * 4);
                                        disp += 3;
-                                       CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4 + 4);
+                                       CALCOFFSETBYTES(disp, REG_SP, iptr->s1.var->vv.regoff * 4 + 4);
 
                                        disp += 2;
                                        disp += 3;
@@ -1415,46 +1047,46 @@ bool codegen(jitdata *jd)
 
                                        /* TODO: hmm, don't know if this is always correct */
                                        disp += 2;
-                                       CALCIMMEDIATEBYTES(disp, iptr->val.l & 0x00000000ffffffff);
+                                       CALCIMMEDIATEBYTES(disp, iptr->sx.val.l & 0x00000000ffffffff);
                                        disp += 2;
-                                       CALCIMMEDIATEBYTES(disp, iptr->val.l >> 32);
+                                       CALCIMMEDIATEBYTES(disp, iptr->sx.val.l >> 32);
 
                                        disp += 2;
                                        disp += 3;
                                        disp += 2;
 
-                                       emit_mov_membase_reg(cd, REG_SP, src->regoff * 4, REG_ITMP1);
-                                       emit_mov_membase_reg(cd, REG_SP, src->regoff * 4 + 4, REG_ITMP2);
+                                       emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 4, REG_ITMP1);
+                                       emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 4 + 4, REG_ITMP2);
                                        
-                                       emit_alu_imm_reg(cd, ALU_AND, iptr->val.l, REG_ITMP1);
-                                       emit_alu_imm_reg(cd, ALU_AND, iptr->val.l >> 32, REG_ITMP2);
-                                       emit_alu_imm_membase(cd, ALU_CMP, 0, REG_SP, src->regoff * 4 + 4);
+                                       emit_alu_imm_reg(cd, ALU_AND, iptr->sx.val.l, REG_ITMP1);
+                                       emit_alu_imm_reg(cd, ALU_AND, iptr->sx.val.l >> 32, REG_ITMP2);
+                                       emit_alu_imm_membase(cd, ALU_CMP, 0, REG_SP, iptr->s1.var->vv.regoff * 4 + 4);
                                        emit_jcc(cd, CC_GE, disp);
 
-                                       emit_mov_membase_reg(cd, REG_SP, src->regoff * 4, REG_ITMP1);
-                                       emit_mov_membase_reg(cd, REG_SP, src->regoff * 4 + 4, REG_ITMP2);
+                                       emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 4, REG_ITMP1);
+                                       emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 4 + 4, REG_ITMP2);
                                        
                                        emit_neg_reg(cd, REG_ITMP1);
                                        emit_alu_imm_reg(cd, ALU_ADC, 0, REG_ITMP2);
                                        emit_neg_reg(cd, REG_ITMP2);
                                        
-                                       emit_alu_imm_reg(cd, ALU_AND, iptr->val.l, REG_ITMP1);
-                                       emit_alu_imm_reg(cd, ALU_AND, iptr->val.l >> 32, REG_ITMP2);
+                                       emit_alu_imm_reg(cd, ALU_AND, iptr->sx.val.l, REG_ITMP1);
+                                       emit_alu_imm_reg(cd, ALU_AND, iptr->sx.val.l >> 32, REG_ITMP2);
                                        
                                        emit_neg_reg(cd, REG_ITMP1);
                                        emit_alu_imm_reg(cd, ALU_ADC, 0, REG_ITMP2);
                                        emit_neg_reg(cd, REG_ITMP2);
 
-                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, iptr->dst->regoff * 4);
-                                       emit_mov_reg_membase(cd, REG_ITMP2, REG_SP, iptr->dst->regoff * 4 + 4);
+                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, iptr->dst.var->vv.regoff * 4);
+                                       emit_mov_reg_membase(cd, REG_ITMP2, REG_SP, iptr->dst.var->vv.regoff * 4 + 4);
                                }
                        }
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_RESULT_PACKED);
                        M_LNGMOVE(s1, d);
-                       M_AND_IMM(iptr->val.l, GET_LOW_REG(d)); 
-                       M_AND_IMM(iptr->val.l >> 32, GET_HIGH_REG(d));
+                       M_AND_IMM(iptr->sx.val.l, GET_LOW_REG(d));      
+                       M_AND_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(d));
                        M_TEST(GET_LOW_REG(s1));
                        M_BGE(0);
                        M_LNGMOVE(s1, d);
@@ -1463,72 +1095,72 @@ bool codegen(jitdata *jd)
 
                case ICMD_ISHL:       /* ..., val1, val2  ==> ..., val1 << val2       */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s2, ECX);                       /* s2 may be equal to d */
                        M_INTMOVE(s1, d);
                        M_SLL(d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_ISHLCONST:  /* ..., value  ==> ..., value << constant       */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
-                       M_SLL_IMM(iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_SLL_IMM(iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_ISHR:       /* ..., val1, val2  ==> ..., val1 >> val2       */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s2, ECX);                       /* s2 may be equal to d */
                        M_INTMOVE(s1, d);
                        M_SRA(d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_ISHRCONST:  /* ..., value  ==> ..., value >> constant       */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
-                       M_SRA_IMM(iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_SRA_IMM(iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IUSHR:      /* ..., val1, val2  ==> ..., val1 >>> val2      */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s2, ECX);                       /* s2 may be equal to d */
                        M_INTMOVE(s1, d);
                        M_SRL(d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IUSHRCONST: /* ..., value  ==> ..., value >>> constant      */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
-                       M_SRL_IMM(iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_SRL_IMM(iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LSHL:       /* ..., val1, val2  ==> ..., val1 << val2       */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP13_PACKED);
-                       s2 = emit_load_s2(jd, iptr, src, ECX);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP13_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP13_PACKED);
+                       s2 = emit_load_s2(jd, iptr, ECX);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP13_PACKED);
                        M_LNGMOVE(s1, d);
                        M_INTMOVE(s2, ECX);
                        M_TEST_IMM(32, ECX);
@@ -1537,32 +1169,34 @@ bool codegen(jitdata *jd)
                        M_CLR(GET_LOW_REG(d));
                        M_SLLD(GET_LOW_REG(d), GET_HIGH_REG(d));
                        M_SLL(GET_LOW_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
         case ICMD_LSHLCONST:  /* ..., value  ==> ..., value << constant       */
-                                         /* val.i = constant                             */
+                                         /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_LNGMOVE(s1, d);
-                       if (iptr->val.i & 0x20) {
+                       if (iptr->sx.val.i & 0x20) {
                                M_MOV(GET_LOW_REG(d), GET_HIGH_REG(d));
                                M_CLR(GET_LOW_REG(d));
-                               M_SLLD_IMM(iptr->val.i & 0x3f, GET_LOW_REG(d), GET_HIGH_REG(d));
+                               M_SLLD_IMM(iptr->sx.val.i & 0x3f, GET_LOW_REG(d), 
+                                                  GET_HIGH_REG(d));
                        }
                        else {
-                               M_SLLD_IMM(iptr->val.i & 0x3f, GET_LOW_REG(d), GET_HIGH_REG(d));
-                               M_SLL_IMM(iptr->val.i & 0x3f, GET_LOW_REG(d));
+                               M_SLLD_IMM(iptr->sx.val.i & 0x3f, GET_LOW_REG(d),
+                                                  GET_HIGH_REG(d));
+                               M_SLL_IMM(iptr->sx.val.i & 0x3f, GET_LOW_REG(d));
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LSHR:       /* ..., val1, val2  ==> ..., val1 >> val2       */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP13_PACKED);
-                       s2 = emit_load_s2(jd, iptr, src, ECX);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP13_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP13_PACKED);
+                       s2 = emit_load_s2(jd, iptr, ECX);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP13_PACKED);
                        M_LNGMOVE(s1, d);
                        M_INTMOVE(s2, ECX);
                        M_TEST_IMM(32, ECX);
@@ -1571,32 +1205,34 @@ bool codegen(jitdata *jd)
                        M_SRA_IMM(31, GET_HIGH_REG(d));
                        M_SRLD(GET_HIGH_REG(d), GET_LOW_REG(d));
                        M_SRA(GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LSHRCONST:  /* ..., value  ==> ..., value >> constant       */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_LNGMOVE(s1, d);
-                       if (iptr->val.i & 0x20) {
+                       if (iptr->sx.val.i & 0x20) {
                                M_MOV(GET_HIGH_REG(d), GET_LOW_REG(d));
                                M_SRA_IMM(31, GET_HIGH_REG(d));
-                               M_SRLD_IMM(iptr->val.i & 0x3f, GET_HIGH_REG(d), GET_LOW_REG(d));
+                               M_SRLD_IMM(iptr->sx.val.i & 0x3f, GET_HIGH_REG(d), 
+                                                  GET_LOW_REG(d));
                        }
                        else {
-                               M_SRLD_IMM(iptr->val.i & 0x3f, GET_HIGH_REG(d), GET_LOW_REG(d));
-                               M_SRA_IMM(iptr->val.i & 0x3f, GET_HIGH_REG(d));
+                               M_SRLD_IMM(iptr->sx.val.i & 0x3f, GET_HIGH_REG(d), 
+                                                  GET_LOW_REG(d));
+                               M_SRA_IMM(iptr->sx.val.i & 0x3f, GET_HIGH_REG(d));
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LUSHR:      /* ..., val1, val2  ==> ..., val1 >>> val2      */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP13_PACKED);
-                       s2 = emit_load_s2(jd, iptr, src, ECX);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP13_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP13_PACKED);
+                       s2 = emit_load_s2(jd, iptr, ECX);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP13_PACKED);
                        M_LNGMOVE(s1, d);
                        M_INTMOVE(s2, ECX);
                        M_TEST_IMM(32, ECX);
@@ -1605,56 +1241,58 @@ bool codegen(jitdata *jd)
                        M_CLR(GET_HIGH_REG(d));
                        M_SRLD(GET_HIGH_REG(d), GET_LOW_REG(d));
                        M_SRL(GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LUSHRCONST: /* ..., value  ==> ..., value >>> constant      */
-                                     /* val.l = constant                             */
+                                     /* sx.val.l = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_LNGMOVE(s1, d);
-                       if (iptr->val.i & 0x20) {
+                       if (iptr->sx.val.i & 0x20) {
                                M_MOV(GET_HIGH_REG(d), GET_LOW_REG(d));
                                M_CLR(GET_HIGH_REG(d));
-                               M_SRLD_IMM(iptr->val.i & 0x3f, GET_HIGH_REG(d), GET_LOW_REG(d));
+                               M_SRLD_IMM(iptr->sx.val.i & 0x3f, GET_HIGH_REG(d), 
+                                                  GET_LOW_REG(d));
                        }
                        else {
-                               M_SRLD_IMM(iptr->val.i & 0x3f, GET_HIGH_REG(d), GET_LOW_REG(d));
-                               M_SRL_IMM(iptr->val.i & 0x3f, GET_HIGH_REG(d));
+                               M_SRLD_IMM(iptr->sx.val.i & 0x3f, GET_HIGH_REG(d), 
+                                                  GET_LOW_REG(d));
+                               M_SRL_IMM(iptr->sx.val.i & 0x3f, GET_HIGH_REG(d));
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IAND:       /* ..., val1, val2  ==> ..., val1 & val2        */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s2 == d)
                                M_AND(s1, d);
                        else {
                                M_INTMOVE(s1, d);
                                M_AND(s2, d);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IANDCONST:  /* ..., value  ==> ..., value & constant        */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
-                       M_AND_IMM(iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_AND_IMM(iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LAND:       /* ..., val1, val2  ==> ..., val1 & val2        */
 
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        if (s2 == GET_LOW_REG(d))
                                M_AND(s1, GET_LOW_REG(d));
                        else {
@@ -1662,57 +1300,57 @@ bool codegen(jitdata *jd)
                                M_AND(s2, GET_LOW_REG(d));
                        }
                        /* REG_ITMP1 probably contains low 32-bit of destination */
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP2);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP3);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        if (s2 == GET_HIGH_REG(d))
                                M_AND(s1, GET_HIGH_REG(d));
                        else {
                                M_INTMOVE(s1, GET_HIGH_REG(d));
                                M_AND(s2, GET_HIGH_REG(d));
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LANDCONST:  /* ..., value  ==> ..., value & constant        */
-                                     /* val.l = constant                             */
+                                     /* sx.val.l = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_LNGMOVE(s1, d);
-                       M_AND_IMM(iptr->val.l, GET_LOW_REG(d));
-                       M_AND_IMM(iptr->val.l >> 32, GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_AND_IMM(iptr->sx.val.l, GET_LOW_REG(d));
+                       M_AND_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(d));
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IOR:        /* ..., val1, val2  ==> ..., val1 | val2        */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s2 == d)
                                M_OR(s1, d);
                        else {
                                M_INTMOVE(s1, d);
                                M_OR(s2, d);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IORCONST:   /* ..., value  ==> ..., value | constant        */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
-                       M_OR_IMM(iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_OR_IMM(iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LOR:        /* ..., val1, val2  ==> ..., val1 | val2        */
 
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        if (s2 == GET_LOW_REG(d))
                                M_OR(s1, GET_LOW_REG(d));
                        else {
@@ -1720,57 +1358,57 @@ bool codegen(jitdata *jd)
                                M_OR(s2, GET_LOW_REG(d));
                        }
                        /* REG_ITMP1 probably contains low 32-bit of destination */
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP2);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP3);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        if (s2 == GET_HIGH_REG(d))
                                M_OR(s1, GET_HIGH_REG(d));
                        else {
                                M_INTMOVE(s1, GET_HIGH_REG(d));
                                M_OR(s2, GET_HIGH_REG(d));
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LORCONST:   /* ..., value  ==> ..., value | constant        */
-                                     /* val.l = constant                             */
+                                     /* sx.val.l = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_LNGMOVE(s1, d);
-                       M_OR_IMM(iptr->val.l, GET_LOW_REG(d));
-                       M_OR_IMM(iptr->val.l >> 32, GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_OR_IMM(iptr->sx.val.l, GET_LOW_REG(d));
+                       M_OR_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(d));
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IXOR:       /* ..., val1, val2  ==> ..., val1 ^ val2        */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s2 == d)
                                M_XOR(s1, d);
                        else {
                                M_INTMOVE(s1, d);
                                M_XOR(s2, d);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IXORCONST:  /* ..., value  ==> ..., value ^ constant        */
-                                     /* val.i = constant                             */
+                                     /* sx.val.i = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
-                       M_XOR_IMM(iptr->val.i, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       M_XOR_IMM(iptr->sx.val.i, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LXOR:       /* ..., val1, val2  ==> ..., val1 ^ val2        */
 
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        if (s2 == GET_LOW_REG(d))
                                M_XOR(s1, GET_LOW_REG(d));
                        else {
@@ -1778,83 +1416,26 @@ bool codegen(jitdata *jd)
                                M_XOR(s2, GET_LOW_REG(d));
                        }
                        /* REG_ITMP1 probably contains low 32-bit of destination */
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP2);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP3);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        if (s2 == GET_HIGH_REG(d))
                                M_XOR(s1, GET_HIGH_REG(d));
                        else {
                                M_INTMOVE(s1, GET_HIGH_REG(d));
                                M_XOR(s2, GET_HIGH_REG(d));
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LXORCONST:  /* ..., value  ==> ..., value ^ constant        */
-                                     /* val.l = constant                             */
+                                     /* sx.val.l = constant                          */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP12_PACKED);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        M_LNGMOVE(s1, d);
-                       M_XOR_IMM(iptr->val.l, GET_LOW_REG(d));
-                       M_XOR_IMM(iptr->val.l >> 32, GET_HIGH_REG(d));
-                       emit_store(jd, iptr, iptr->dst, d);
-                       break;
-
-               case ICMD_IINC:       /* ..., value  ==> ..., value + constant        */
-                                     /* op1 = variable, val.i = constant             */
-
-#if defined(ENABLE_SSA)
-                       if ( ls != NULL ) {
-                               varinfo      *var_t;
-                               /* with SSA in op1 is the source Local Var, in val._i.op1_t  */
-                               /* the target Local Var, in val._i.i the constant            */
-                               /* val._i.op1_t <- op1 + val._i.i                            */
-
-                               
-                               var = &(rd->locals[iptr->op1][TYPE_INT]);
-                               var_t = &(rd->locals[iptr->val._i.op1_t][TYPE_INT]);
-
-                               /* set s1 to reg of destination or REG_ITMP1 */
-                               if (var_t->flags & INMEMORY)
-                                       s1 = REG_ITMP1;
-                               else
-                                       s1 = var_t->regoff;
-
-                               /* move source value to s1 */
-                               if (var->flags & INMEMORY)
-                                       M_ILD( s1, REG_SP, var->regoff * 4);
-                               else
-                                       M_INTMOVE(var->regoff, s1);
-
-                               /* `inc reg' is slower on p4's (regarding to ia32
-                                  optimization reference manual and benchmarks) and as
-                                  fast on athlon's. */
-
-                               M_IADD_IMM(iptr->val._i.i, s1);
-
-                               if (var_t->flags & INMEMORY)
-                                       M_IST(s1, REG_SP, var_t->regoff * 4);
-
-                       } else
-#endif /* defined(ENABLE_SSA) */
-                       {
-                               var = &(rd->locals[iptr->op1][TYPE_INT]);
-                               if (var->flags & INMEMORY) {
-                                       s1 = REG_ITMP1;
-                                       M_ILD(s1, REG_SP, var->regoff * 4);
-                               }
-                               else 
-                                       s1 = var->regoff;
-
-                               /* `inc reg' is slower on p4's (regarding to ia32
-                                  optimization reference manual and benchmarks) and as
-                                  fast on athlon's. */
-
-                               M_IADD_IMM(iptr->val.i, s1);
-
-                               if (var->flags & INMEMORY)
-                                       M_IST(s1, REG_SP, var->regoff * 4);
-                       }
+                       M_XOR_IMM(iptr->sx.val.l, GET_LOW_REG(d));
+                       M_XOR_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(d));
+                       emit_store_dst(jd, iptr, d);
                        break;
 
 
@@ -1862,105 +1443,105 @@ bool codegen(jitdata *jd)
 
                case ICMD_FNEG:       /* ..., value  ==> ..., - value                 */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
                        emit_fchs(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_DNEG:       /* ..., value  ==> ..., - value                 */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
                        emit_fchs(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_FADD:       /* ..., val1, val2  ==> ..., val1 + val2        */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        emit_faddp(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_DADD:       /* ..., val1, val2  ==> ..., val1 + val2        */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        emit_faddp(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_FSUB:       /* ..., val1, val2  ==> ..., val1 - val2        */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        emit_fsubp(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_DSUB:       /* ..., val1, val2  ==> ..., val1 - val2        */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        emit_fsubp(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_FMUL:       /* ..., val1, val2  ==> ..., val1 * val2        */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        emit_fmulp(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_DMUL:       /* ..., val1, val2  ==> ..., val1 * val2        */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        emit_fmulp(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_FDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        emit_fdivp(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_DDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        emit_fdivp(cd);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_FREM:       /* ..., val1, val2  ==> ..., val1 % val2        */
 
                        /* exchanged to skip fxch */
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
 /*                     emit_fxch(cd); */
                        emit_fprem(cd);
                        emit_wait(cd);
                        emit_fnstsw(cd);
                        emit_sahf(cd);
                        emit_jcc(cd, CC_P, -(2 + 1 + 2 + 1 + 6));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        emit_ffree_reg(cd, 0);
                        emit_fincstp(cd);
                        break;
@@ -1968,16 +1549,16 @@ bool codegen(jitdata *jd)
                case ICMD_DREM:       /* ..., val1, val2  ==> ..., val1 % val2        */
 
                        /* exchanged to skip fxch */
-                       s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
 /*                     emit_fxch(cd); */
                        emit_fprem(cd);
                        emit_wait(cd);
                        emit_fnstsw(cd);
                        emit_sahf(cd);
                        emit_jcc(cd, CC_P, -(2 + 1 + 2 + 1 + 6));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        emit_ffree_reg(cd, 0);
                        emit_fincstp(cd);
                        break;
@@ -1985,195 +1566,215 @@ bool codegen(jitdata *jd)
                case ICMD_I2F:       /* ..., value  ==> ..., (float) value            */
                case ICMD_I2D:       /* ..., value  ==> ..., (double) value           */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
-                       if (src->flags & INMEMORY) {
-                               emit_fildl_membase(cd, REG_SP, src->regoff * 4);
+                       var = VAROP(iptr->s1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
 
+                       if (var->flags & INMEMORY) {
+                               emit_fildl_membase(cd, REG_SP, var->vv.regoff * 4);
                        } else {
-                               disp = dseg_adds4(cd, 0);
+                               /* XXX not thread safe! */
+                               disp = dseg_add_unique_s4(cd, 0);
                                emit_mov_imm_reg(cd, 0, REG_ITMP1);
                                dseg_adddata(cd);
-                               emit_mov_reg_membase(cd, src->regoff, REG_ITMP1, disp);
+                               emit_mov_reg_membase(cd, var->vv.regoff, REG_ITMP1, disp);
                                emit_fildl_membase(cd, REG_ITMP1, disp);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_L2F:       /* ..., value  ==> ..., (float) value            */
                case ICMD_L2D:       /* ..., value  ==> ..., (double) value           */
 
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
-                       if (src->flags & INMEMORY) {
-                               emit_fildll_membase(cd, REG_SP, src->regoff * 4);
+                       var = VAROP(iptr->s1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                       if (var->flags & INMEMORY) {
+                               emit_fildll_membase(cd, REG_SP, var->vv.regoff * 4);
 
                        } else {
                                log_text("L2F: longs have to be in memory");
                                assert(0);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
                        
                case ICMD_F2I:       /* ..., value  ==> ..., (int) value              */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_NULL);
 
                        emit_mov_imm_reg(cd, 0, REG_ITMP1);
                        dseg_adddata(cd);
 
                        /* Round to zero, 53-bit mode, exception masked */
-                       disp = dseg_adds4(cd, 0x0e7f);
+                       disp = dseg_add_s4(cd, 0x0e7f);
                        emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                       if (iptr->dst->flags & INMEMORY) {
-                               emit_fistpl_membase(cd, REG_SP, iptr->dst->regoff * 4);
+                       var = VAROP(iptr->dst);
+                       var1 = VAROP(iptr->s1);
+
+                       if (var->flags & INMEMORY) {
+                               emit_fistpl_membase(cd, REG_SP, var->vv.regoff * 4);
 
                                /* Round to nearest, 53-bit mode, exceptions masked */
-                               disp = dseg_adds4(cd, 0x027f);
+                               disp = dseg_add_s4(cd, 0x027f);
                                emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                               emit_alu_imm_membase(cd, ALU_CMP, 0x80000000, REG_SP, iptr->dst->regoff * 4);
+                               emit_alu_imm_membase(cd, ALU_CMP, 0x80000000, 
+                                                                        REG_SP, var->vv.regoff * 4);
 
                                disp = 3;
-                               CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var1->vv.regoff * 4);
                                disp += 5 + 2 + 3;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4);
 
                        } else {
-                               disp = dseg_adds4(cd, 0);
+                               /* XXX not thread safe! */
+                               disp = dseg_add_unique_s4(cd, 0);
                                emit_fistpl_membase(cd, REG_ITMP1, disp);
-                               emit_mov_membase_reg(cd, REG_ITMP1, disp, iptr->dst->regoff);
+                               emit_mov_membase_reg(cd, REG_ITMP1, disp, var->vv.regoff);
 
                                /* Round to nearest, 53-bit mode, exceptions masked */
-                               disp = dseg_adds4(cd, 0x027f);
+                               disp = dseg_add_s4(cd, 0x027f);
                                emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                               emit_alu_imm_reg(cd, ALU_CMP, 0x80000000, iptr->dst->regoff);
+                               emit_alu_imm_reg(cd, ALU_CMP, 0x80000000, var->vv.regoff);
 
                                disp = 3;
-                               CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4);
-                               disp += 5 + 2 + ((REG_RESULT == iptr->dst->regoff) ? 0 : 2);
+                               CALCOFFSETBYTES(disp, REG_SP, var1->vv.regoff * 4);
+                               disp += 5 + 2 + ((REG_RESULT == var->vv.regoff) ? 0 : 2);
                        }
 
                        emit_jcc(cd, CC_NE, disp);
 
                        /* XXX: change this when we use registers */
-                       emit_flds_membase(cd, REG_SP, src->regoff * 4);
+                       emit_flds_membase(cd, REG_SP, var1->vv.regoff * 4);
                        emit_mov_imm_reg(cd, (ptrint) asm_builtin_f2i, REG_ITMP1);
                        emit_call_reg(cd, REG_ITMP1);
 
-                       if (iptr->dst->flags & INMEMORY) {
-                               emit_mov_reg_membase(cd, REG_RESULT, REG_SP, iptr->dst->regoff * 4);
+                       if (var->flags & INMEMORY) {
+                               emit_mov_reg_membase(cd, REG_RESULT, REG_SP, var->vv.regoff * 4);
 
                        } else {
-                               M_INTMOVE(REG_RESULT, iptr->dst->regoff);
+                               M_INTMOVE(REG_RESULT, var->vv.regoff);
                        }
                        break;
 
                case ICMD_D2I:       /* ..., value  ==> ..., (int) value              */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_NULL);
 
                        emit_mov_imm_reg(cd, 0, REG_ITMP1);
                        dseg_adddata(cd);
 
                        /* Round to zero, 53-bit mode, exception masked */
-                       disp = dseg_adds4(cd, 0x0e7f);
+                       disp = dseg_add_s4(cd, 0x0e7f);
                        emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                       if (iptr->dst->flags & INMEMORY) {
-                               emit_fistpl_membase(cd, REG_SP, iptr->dst->regoff * 4);
+                       var  = VAROP(iptr->dst);
+                       var1 = VAROP(iptr->s1);
+
+                       if (var->flags & INMEMORY) {
+                               emit_fistpl_membase(cd, REG_SP, var->vv.regoff * 4);
 
                                /* Round to nearest, 53-bit mode, exceptions masked */
-                               disp = dseg_adds4(cd, 0x027f);
+                               disp = dseg_add_s4(cd, 0x027f);
                                emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                               emit_alu_imm_membase(cd, ALU_CMP, 0x80000000, REG_SP, iptr->dst->regoff * 4);
+                               emit_alu_imm_membase(cd, ALU_CMP, 0x80000000, 
+                                                                        REG_SP, var->vv.regoff * 4);
 
                                disp = 3;
-                               CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var1->vv.regoff * 4);
                                disp += 5 + 2 + 3;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4);
 
                        } else {
-                               disp = dseg_adds4(cd, 0);
+                               /* XXX not thread safe! */
+                               disp = dseg_add_unique_s4(cd, 0);
                                emit_fistpl_membase(cd, REG_ITMP1, disp);
-                               emit_mov_membase_reg(cd, REG_ITMP1, disp, iptr->dst->regoff);
+                               emit_mov_membase_reg(cd, REG_ITMP1, disp, var->vv.regoff);
 
                                /* Round to nearest, 53-bit mode, exceptions masked */
-                               disp = dseg_adds4(cd, 0x027f);
+                               disp = dseg_add_s4(cd, 0x027f);
                                emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                               emit_alu_imm_reg(cd, ALU_CMP, 0x80000000, iptr->dst->regoff);
+                               emit_alu_imm_reg(cd, ALU_CMP, 0x80000000, var->vv.regoff);
 
                                disp = 3;
-                               CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4);
-                               disp += 5 + 2 + ((REG_RESULT == iptr->dst->regoff) ? 0 : 2);
+                               CALCOFFSETBYTES(disp, REG_SP, var1->vv.regoff * 4);
+                               disp += 5 + 2 + ((REG_RESULT == var->vv.regoff) ? 0 : 2);
                        }
 
                        emit_jcc(cd, CC_NE, disp);
 
                        /* XXX: change this when we use registers */
-                       emit_fldl_membase(cd, REG_SP, src->regoff * 4);
+                       emit_fldl_membase(cd, REG_SP, var1->vv.regoff * 4);
                        emit_mov_imm_reg(cd, (ptrint) asm_builtin_d2i, REG_ITMP1);
                        emit_call_reg(cd, REG_ITMP1);
 
-                       if (iptr->dst->flags & INMEMORY) {
-                               emit_mov_reg_membase(cd, REG_RESULT, REG_SP, iptr->dst->regoff * 4);
+                       if (var->flags & INMEMORY) {
+                               emit_mov_reg_membase(cd, REG_RESULT, REG_SP, var->vv.regoff * 4);
                        } else {
-                               M_INTMOVE(REG_RESULT, iptr->dst->regoff);
+                               M_INTMOVE(REG_RESULT, var->vv.regoff);
                        }
                        break;
 
                case ICMD_F2L:       /* ..., value  ==> ..., (long) value             */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_NULL);
 
                        emit_mov_imm_reg(cd, 0, REG_ITMP1);
                        dseg_adddata(cd);
 
                        /* Round to zero, 53-bit mode, exception masked */
-                       disp = dseg_adds4(cd, 0x0e7f);
+                       disp = dseg_add_s4(cd, 0x0e7f);
                        emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                       if (iptr->dst->flags & INMEMORY) {
-                               emit_fistpll_membase(cd, REG_SP, iptr->dst->regoff * 4);
+                       var  = VAROP(iptr->dst);
+                       var1 = VAROP(iptr->s1);
+
+                       if (var->flags & INMEMORY) {
+                               emit_fistpll_membase(cd, REG_SP, var->vv.regoff * 4);
 
                                /* Round to nearest, 53-bit mode, exceptions masked */
-                               disp = dseg_adds4(cd, 0x027f);
+                               disp = dseg_add_s4(cd, 0x027f);
                                emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                               emit_alu_imm_membase(cd, ALU_CMP, 0x80000000, REG_SP, iptr->dst->regoff * 4 + 4);
+                               emit_alu_imm_membase(cd, ALU_CMP, 0x80000000, 
+                                                                        REG_SP, var->vv.regoff * 4 + 4);
 
                                disp = 6 + 4;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4);
                                disp += 3;
-                               CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var1->vv.regoff * 4);
                                disp += 5 + 2;
                                disp += 3;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4);
                                disp += 3;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4 + 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4 + 4);
 
                                emit_jcc(cd, CC_NE, disp);
 
-                               emit_alu_imm_membase(cd, ALU_CMP, 0, REG_SP, iptr->dst->regoff * 4);
+                               emit_alu_imm_membase(cd, ALU_CMP, 0, 
+                                                                        REG_SP, var->vv.regoff * 4);
 
                                disp = 3;
-                               CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var1->vv.regoff * 4);
                                disp += 5 + 2 + 3;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4);
 
                                emit_jcc(cd, CC_NE, disp);
 
                                /* XXX: change this when we use registers */
-                               emit_flds_membase(cd, REG_SP, src->regoff * 4);
+                               emit_flds_membase(cd, REG_SP, var1->vv.regoff * 4);
                                emit_mov_imm_reg(cd, (ptrint) asm_builtin_f2l, REG_ITMP1);
                                emit_call_reg(cd, REG_ITMP1);
-                               emit_mov_reg_membase(cd, REG_RESULT, REG_SP, iptr->dst->regoff * 4);
-                               emit_mov_reg_membase(cd, REG_RESULT2, REG_SP, iptr->dst->regoff * 4 + 4);
+                               emit_mov_reg_membase(cd, REG_RESULT, REG_SP, var->vv.regoff * 4);
+                               emit_mov_reg_membase(cd, REG_RESULT2, 
+                                                                        REG_SP, var->vv.regoff * 4 + 4);
 
                        } else {
                                log_text("F2L: longs have to be in memory");
@@ -2183,52 +1784,57 @@ bool codegen(jitdata *jd)
 
                case ICMD_D2L:       /* ..., value  ==> ..., (long) value             */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_NULL);
 
                        emit_mov_imm_reg(cd, 0, REG_ITMP1);
                        dseg_adddata(cd);
 
                        /* Round to zero, 53-bit mode, exception masked */
-                       disp = dseg_adds4(cd, 0x0e7f);
+                       disp = dseg_add_s4(cd, 0x0e7f);
                        emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                       if (iptr->dst->flags & INMEMORY) {
-                               emit_fistpll_membase(cd, REG_SP, iptr->dst->regoff * 4);
+                       var  = VAROP(iptr->dst);
+                       var1 = VAROP(iptr->s1);
+
+                       if (var->flags & INMEMORY) {
+                               emit_fistpll_membase(cd, REG_SP, var->vv.regoff * 4);
 
                                /* Round to nearest, 53-bit mode, exceptions masked */
-                               disp = dseg_adds4(cd, 0x027f);
+                               disp = dseg_add_s4(cd, 0x027f);
                                emit_fldcw_membase(cd, REG_ITMP1, disp);
 
-                               emit_alu_imm_membase(cd, ALU_CMP, 0x80000000, REG_SP, iptr->dst->regoff * 4 + 4);
+                               emit_alu_imm_membase(cd, ALU_CMP, 0x80000000, 
+                                                                        REG_SP, var->vv.regoff * 4 + 4);
 
                                disp = 6 + 4;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4);
                                disp += 3;
-                               CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var1->vv.regoff * 4);
                                disp += 5 + 2;
                                disp += 3;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4);
                                disp += 3;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4 + 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4 + 4);
 
                                emit_jcc(cd, CC_NE, disp);
 
-                               emit_alu_imm_membase(cd, ALU_CMP, 0, REG_SP, iptr->dst->regoff * 4);
+                               emit_alu_imm_membase(cd, ALU_CMP, 0, REG_SP, var->vv.regoff * 4);
 
                                disp = 3;
-                               CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var1->vv.regoff * 4);
                                disp += 5 + 2 + 3;
-                               CALCOFFSETBYTES(disp, REG_SP, iptr->dst->regoff * 4);
+                               CALCOFFSETBYTES(disp, REG_SP, var->vv.regoff * 4);
 
                                emit_jcc(cd, CC_NE, disp);
 
                                /* XXX: change this when we use registers */
-                               emit_fldl_membase(cd, REG_SP, src->regoff * 4);
+                               emit_fldl_membase(cd, REG_SP, var1->vv.regoff * 4);
                                emit_mov_imm_reg(cd, (ptrint) asm_builtin_d2l, REG_ITMP1);
                                emit_call_reg(cd, REG_ITMP1);
-                               emit_mov_reg_membase(cd, REG_RESULT, REG_SP, iptr->dst->regoff * 4);
-                               emit_mov_reg_membase(cd, REG_RESULT2, REG_SP, iptr->dst->regoff * 4 + 4);
+                               emit_mov_reg_membase(cd, REG_RESULT, REG_SP, var->vv.regoff * 4);
+                               emit_mov_reg_membase(cd, REG_RESULT2, 
+                                                                        REG_SP, var->vv.regoff * 4 + 4);
 
                        } else {
                                log_text("D2L: longs have to be in memory");
@@ -2238,27 +1844,27 @@ bool codegen(jitdata *jd)
 
                case ICMD_F2D:       /* ..., value  ==> ..., (double) value           */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
                        /* nothing to do */
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_D2F:       /* ..., value  ==> ..., (float) value            */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
                        /* nothing to do */
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_FCMPL:      /* ..., val1, val2  ==> ..., val1 fcmpl val2    */
                case ICMD_DCMPL:
 
                        /* exchanged to skip fxch */
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_FTMP1);
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s2 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s1 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
 /*                     emit_fxch(cd); */
                        emit_fucompp(cd);
                        emit_fnstsw(cd);
@@ -2272,16 +1878,16 @@ bool codegen(jitdata *jd)
                        emit_alu_imm_reg(cd, ALU_SUB, 1, d);
                        emit_jmp_imm(cd, 3);
                        emit_alu_imm_reg(cd, ALU_ADD, 1, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_FCMPG:      /* ..., val1, val2  ==> ..., val1 fcmpg val2    */
                case ICMD_DCMPG:
 
                        /* exchanged to skip fxch */
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_FTMP1);
-                       s1 = emit_load_s1(jd, iptr, src, REG_FTMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
+                       s2 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s1 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
 /*                     emit_fxch(cd); */
                        emit_fucompp(cd);
                        emit_fnstsw(cd);
@@ -2295,7 +1901,7 @@ bool codegen(jitdata *jd)
                        emit_alu_imm_reg(cd, ALU_SUB, 1, d);
                        emit_jmp_imm(cd, 3);
                        emit_alu_imm_reg(cd, ALU_ADD, 1, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
 
@@ -2303,221 +1909,194 @@ bool codegen(jitdata *jd)
 
                case ICMD_ARRAYLENGTH: /* ..., arrayref  ==> ..., length              */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
-                       gen_nullptr_check(s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       emit_nullpointer_check(cd, iptr, s1);
                        M_ILD(d, s1, OFFSET(java_arrayheader, size));
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_BALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_movsbl_memindex_reg(cd, OFFSET(java_bytearray, data[0]), s1, s2, 0, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_movsbl_memindex_reg(cd, OFFSET(java_bytearray, data[0]), 
+                                                                        s1, s2, 0, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_CALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_movzwl_memindex_reg(cd, OFFSET(java_chararray, data[0]), s1, s2, 1, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_movzwl_memindex_reg(cd, OFFSET(java_chararray, data[0]), 
+                                                                        s1, s2, 1, d);
+                       emit_store_dst(jd, iptr, d);
                        break;                  
 
                case ICMD_SALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_movswl_memindex_reg(cd, OFFSET(java_shortarray, data[0]), s1, s2, 1, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_movswl_memindex_reg(cd, OFFSET(java_shortarray, data[0]), 
+                                                                        s1, s2, 1, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_mov_memindex_reg(cd, OFFSET(java_intarray, data[0]), s1, s2, 2, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_mov_memindex_reg(cd, OFFSET(java_intarray, data[0]), 
+                                                                 s1, s2, 2, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_LALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP3);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       assert(iptr->dst->flags & INMEMORY);
-                       emit_mov_memindex_reg(cd, OFFSET(java_longarray, data[0]), s1, s2, 3, REG_ITMP3);
-                       emit_mov_reg_membase(cd, REG_ITMP3, REG_SP, iptr->dst->regoff * 4);
-                       emit_mov_memindex_reg(cd, OFFSET(java_longarray, data[0]) + 4, s1, s2, 3, REG_ITMP3);
-                       emit_mov_reg_membase(cd, REG_ITMP3, REG_SP, iptr->dst->regoff * 4 + 4);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
+                       emit_array_checks(cd, iptr, s1, s2);
+
+                       var = VAROP(iptr->dst);
+
+                       assert(var->flags & INMEMORY);
+                       emit_mov_memindex_reg(cd, OFFSET(java_longarray, data[0]), 
+                                                                 s1, s2, 3, REG_ITMP3);
+                       emit_mov_reg_membase(cd, REG_ITMP3, REG_SP, var->vv.regoff * 4);
+                       emit_mov_memindex_reg(cd, OFFSET(java_longarray, data[0]) + 4, 
+                                                                 s1, s2, 3, REG_ITMP3);
+                       emit_mov_reg_membase(cd, REG_ITMP3, REG_SP, var->vv.regoff * 4 + 4);
                        break;
 
                case ICMD_FALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                       emit_array_checks(cd, iptr, s1, s2);
                        emit_flds_memindex(cd, OFFSET(java_floatarray, data[0]), s1, s2, 2);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_DALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_fldl_memindex(cd, OFFSET(java_doublearray, data[0]), s1, s2, 3);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_fldl_memindex(cd, OFFSET(java_doublearray, data[0]), s1, s2,3);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_AALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_mov_memindex_reg(cd, OFFSET(java_objectarray, data[0]), s1, s2, 2, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_mov_memindex_reg(cd, OFFSET(java_objectarray, data[0]),
+                                                                 s1, s2, 2, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
 
                case ICMD_BASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       s3 = emit_load_s3(jd, iptr, src, REG_ITMP3);
-                       if (s3 >= EBP) { /* because EBP, ESI, EDI have no xH and xL nibbles */
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       s3 = emit_load_s3(jd, iptr, REG_ITMP3);
+                       if (s3 >= EBP) { 
+                               /* because EBP, ESI, EDI have no xH and xL nibbles */
                                M_INTMOVE(s3, REG_ITMP3);
                                s3 = REG_ITMP3;
                        }
-                       emit_movb_reg_memindex(cd, s3, OFFSET(java_bytearray, data[0]), s1, s2, 0);
+                       emit_movb_reg_memindex(cd, s3, OFFSET(java_bytearray, data[0]),
+                                                                  s1, s2, 0);
                        break;
 
                case ICMD_CASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       s3 = emit_load_s3(jd, iptr, src, REG_ITMP3);
-                       emit_movw_reg_memindex(cd, s3, OFFSET(java_chararray, data[0]), s1, s2, 1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       s3 = emit_load_s3(jd, iptr, REG_ITMP3);
+                       emit_movw_reg_memindex(cd, s3, OFFSET(java_chararray, data[0]),
+                                                                  s1, s2, 1);
                        break;
 
                case ICMD_SASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       s3 = emit_load_s3(jd, iptr, src, REG_ITMP3);
-                       emit_movw_reg_memindex(cd, s3, OFFSET(java_shortarray, data[0]), s1, s2, 1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       s3 = emit_load_s3(jd, iptr, REG_ITMP3);
+                       emit_movw_reg_memindex(cd, s3, OFFSET(java_shortarray, data[0]),
+                                                                  s1, s2, 1);
                        break;
 
                case ICMD_IASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       s3 = emit_load_s3(jd, iptr, src, REG_ITMP3);
-                       emit_mov_reg_memindex(cd, s3, OFFSET(java_intarray, data[0]), s1, s2, 2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       s3 = emit_load_s3(jd, iptr, REG_ITMP3);
+                       emit_mov_reg_memindex(cd, s3, OFFSET(java_intarray, data[0]),
+                                                                 s1, s2, 2);
                        break;
 
                case ICMD_LASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       assert(src->flags & INMEMORY);
-                       emit_mov_membase_reg(cd, REG_SP, src->regoff * 4, REG_ITMP3);
-                       emit_mov_reg_memindex(cd, REG_ITMP3, OFFSET(java_longarray, data[0]), s1, s2, 3);
-                       emit_mov_membase_reg(cd, REG_SP, src->regoff * 4 + 4, REG_ITMP3);
-                       emit_mov_reg_memindex(cd, REG_ITMP3, OFFSET(java_longarray, data[0]) + 4, s1, s2, 3);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+
+                       var = VAROP(iptr->sx.s23.s3);
+
+                       assert(var->flags & INMEMORY);
+                       emit_mov_membase_reg(cd, REG_SP, var->vv.regoff * 4, REG_ITMP3);
+                       emit_mov_reg_memindex(cd, REG_ITMP3, OFFSET(java_longarray, data[0])
+                                                                 , s1, s2, 3);
+                       emit_mov_membase_reg(cd, REG_SP, var->vv.regoff * 4 + 4, REG_ITMP3);
+                       emit_mov_reg_memindex(cd, REG_ITMP3,
+                                                           OFFSET(java_longarray, data[0]) + 4, s1, s2, 3);
                        break;
 
                case ICMD_FASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       s3 = emit_load_s3(jd, iptr, src, REG_FTMP1);
-                       emit_fstps_memindex(cd, OFFSET(java_floatarray, data[0]), s1, s2, 2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       s3 = emit_load_s3(jd, iptr, REG_FTMP1);
+                       emit_fstps_memindex(cd, OFFSET(java_floatarray, data[0]), s1, s2,2);
                        break;
 
                case ICMD_DASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       s3 = emit_load_s3(jd, iptr, src, REG_FTMP1);
-                       emit_fstpl_memindex(cd, OFFSET(java_doublearray, data[0]), s1, s2, 3);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       s3 = emit_load_s3(jd, iptr, REG_FTMP1);
+                       emit_fstpl_memindex(cd, OFFSET(java_doublearray, data[0]),
+                                                               s1, s2, 3);
                        break;
 
                case ICMD_AASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       s3 = emit_load_s3(jd, iptr, src, REG_ITMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       s3 = emit_load_s3(jd, iptr, REG_ITMP3);
 
                        M_AST(s1, REG_SP, 0 * 4);
                        M_AST(s3, REG_SP, 1 * 4);
@@ -2527,86 +2106,81 @@ bool codegen(jitdata *jd)
                        M_BEQ(0);
                        codegen_add_arraystoreexception_ref(cd);
 
-                       s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2);
-                       s3 = emit_load_s3(jd, iptr, src, REG_ITMP3);
-                       emit_mov_reg_memindex(cd, s3, OFFSET(java_objectarray, data[0]), s1, s2, 2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       s3 = emit_load_s3(jd, iptr, REG_ITMP3);
+                       emit_mov_reg_memindex(cd, s3, OFFSET(java_objectarray, data[0]),
+                                                                 s1, s2, 2);
                        break;
 
                case ICMD_BASTORECONST: /* ..., arrayref, index  ==> ...              */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_movb_imm_memindex(cd, iptr->val.i, OFFSET(java_bytearray, data[0]), s1, s2, 0);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_movb_imm_memindex(cd, iptr->sx.s23.s3.constval,
+                                                                  OFFSET(java_bytearray, data[0]), s1, s2, 0);
                        break;
 
                case ICMD_CASTORECONST:   /* ..., arrayref, index  ==> ...            */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_movw_imm_memindex(cd, iptr->val.i, OFFSET(java_chararray, data[0]), s1, s2, 1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_movw_imm_memindex(cd, iptr->sx.s23.s3.constval,
+                                                                  OFFSET(java_chararray, data[0]), s1, s2, 1);
                        break;
 
                case ICMD_SASTORECONST:   /* ..., arrayref, index  ==> ...            */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_movw_imm_memindex(cd, iptr->val.i, OFFSET(java_shortarray, data[0]), s1, s2, 1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_movw_imm_memindex(cd, iptr->sx.s23.s3.constval,
+                                                                  OFFSET(java_shortarray, data[0]), s1, s2, 1);
                        break;
 
                case ICMD_IASTORECONST: /* ..., arrayref, index  ==> ...              */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_mov_imm_memindex(cd, iptr->val.i, OFFSET(java_intarray, data[0]), s1, s2, 2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_mov_imm_memindex(cd, iptr->sx.s23.s3.constval,
+                                                                 OFFSET(java_intarray, data[0]), s1, s2, 2);
                        break;
 
                case ICMD_LASTORECONST: /* ..., arrayref, index  ==> ...              */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_mov_imm_memindex(cd, (u4) (iptr->val.l & 0x00000000ffffffff), OFFSET(java_longarray, data[0]), s1, s2, 3);
-                       emit_mov_imm_memindex(cd, (u4) (iptr->val.l >> 32), OFFSET(java_longarray, data[0]) + 4, s1, s2, 3);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_mov_imm_memindex(cd, 
+                                                  (u4) (iptr->sx.s23.s3.constval & 0x00000000ffffffff),
+                                                  OFFSET(java_longarray, data[0]), s1, s2, 3);
+                       emit_mov_imm_memindex(cd, 
+                                                       ((s4)iptr->sx.s23.s3.constval) >> 31, 
+                                                       OFFSET(java_longarray, data[0]) + 4, s1, s2, 3);
                        break;
 
                case ICMD_AASTORECONST: /* ..., arrayref, index  ==> ...              */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                       if (iptr->op1 == 0) {
-                               gen_nullptr_check(s1);
-                               gen_bound_check;
-                       }
-                       emit_mov_imm_memindex(cd, 0, OFFSET(java_objectarray, data[0]), s1, s2, 2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       emit_array_checks(cd, iptr, s1, s2);
+                       emit_mov_imm_memindex(cd, 0, 
+                                                                 OFFSET(java_objectarray, data[0]), s1, s2, 2);
                        break;
 
 
                case ICMD_GETSTATIC:  /* ...  ==> ..., value                          */
-                                     /* op1 = type, val.a = field address            */
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+                               unresolved_field *uf = iptr->sx.s23.s3.uf;
+
+                               fieldtype = uf->fieldref->parseddesc.fd->type;
+
                                codegen_addpatchref(cd, PATCHER_get_putstatic,
-                                                                       INSTRUCTION_UNRESOLVED_FIELD(iptr), 0);
+                                                                       iptr->sx.s23.s3.uf, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -2616,7 +2190,9 @@ bool codegen(jitdata *jd)
 
                        }
                        else {
-                               fieldinfo *fi = INSTRUCTION_RESOLVED_FIELDINFO(iptr);
+                               fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field;
+
+                               fieldtype = fi->type;
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
                                        codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0);
@@ -2630,34 +2206,37 @@ bool codegen(jitdata *jd)
                        }
 
                        M_MOV_IMM(disp, REG_ITMP1);
-                       switch (iptr->op1) {
+                       switch (fieldtype) {
                        case TYPE_INT:
                        case TYPE_ADR:
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                               d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                                M_ILD(d, REG_ITMP1, 0);
                                break;
                        case TYPE_LNG:
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP23_PACKED);
+                               d = codegen_reg_of_dst(jd, iptr, REG_ITMP23_PACKED);
                                M_LLD(d, REG_ITMP1, 0);
                                break;
                        case TYPE_FLT:
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
+                               d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
                                M_FLD(d, REG_ITMP1, 0);
                                break;
                        case TYPE_DBL:                          
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
+                               d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
                                M_DLD(d, REG_ITMP1, 0);
                                break;
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_PUTSTATIC:  /* ..., value  ==> ...                          */
-                                     /* op1 = type, val.a = field address            */
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+                               unresolved_field *uf = iptr->sx.s23.s3.uf;
+
+                               fieldtype = uf->fieldref->parseddesc.fd->type;
+
                                codegen_addpatchref(cd, PATCHER_get_putstatic,
-                                                                       INSTRUCTION_UNRESOLVED_FIELD(iptr), 0);
+                                                                       iptr->sx.s23.s3.uf, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -2667,7 +2246,9 @@ bool codegen(jitdata *jd)
 
                        }
                        else {
-                               fieldinfo *fi = INSTRUCTION_RESOLVED_FIELDINFO(iptr);
+                               fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field;
+                               
+                               fieldtype = fi->type;
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
                                        codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0);
@@ -2681,22 +2262,22 @@ bool codegen(jitdata *jd)
                        }
 
                        M_MOV_IMM(disp, REG_ITMP1);
-                       switch (iptr->op1) {
+                       switch (fieldtype) {
                        case TYPE_INT:
                        case TYPE_ADR:
-                               s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                               M_IST(s2, REG_ITMP1, 0);
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP2);
+                               M_IST(s1, REG_ITMP1, 0);
                                break;
                        case TYPE_LNG:
-                               s2 = emit_load_s2(jd, iptr, src, REG_ITMP23_PACKED);
-                               M_LST(s2, REG_ITMP1, 0);
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP23_PACKED);
+                               M_LST(s1, REG_ITMP1, 0);
                                break;
                        case TYPE_FLT:
-                               s2 = emit_load_s2(jd, iptr, src, REG_FTMP1);
+                               s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                                emit_fstps_membase(cd, REG_ITMP1, 0);
                                break;
                        case TYPE_DBL:
-                               s2 = emit_load_s2(jd, iptr, src, REG_FTMP1);
+                               s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                                emit_fstpl_membase(cd, REG_ITMP1, 0);
                                break;
                        }
@@ -2704,12 +2285,15 @@ bool codegen(jitdata *jd)
 
                case ICMD_PUTSTATICCONST: /* ...  ==> ...                             */
                                          /* val = value (in current instruction)     */
-                                         /* op1 = type, val.a = field address (in    */
                                          /* following NOP)                           */
 
-                       if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) {
+                       if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+                               unresolved_field *uf = iptr->sx.s23.s3.uf;
+
+                               fieldtype = uf->fieldref->parseddesc.fd->type;
+
                                codegen_addpatchref(cd, PATCHER_get_putstatic,
-                                                                       INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), 0);
+                                                                       uf, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -2719,7 +2303,9 @@ bool codegen(jitdata *jd)
 
                        }
                        else {
-                               fieldinfo *fi = INSTRUCTION_RESOLVED_FIELDINFO(iptr + 1);
+                               fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field;
+
+                               fieldtype = fi->type;
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
                                        codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0);
@@ -2733,28 +2319,32 @@ bool codegen(jitdata *jd)
                        }
 
                        M_MOV_IMM(disp, REG_ITMP1);
-                       switch (iptr[1].op1) {
+                       switch (fieldtype) {
                        case TYPE_INT:
-                       case TYPE_FLT:
                        case TYPE_ADR:
-                               M_IST_IMM(iptr->val.i, REG_ITMP1, 0);
+                               M_IST_IMM(iptr->sx.s23.s2.constval, REG_ITMP1, 0);
                                break;
                        case TYPE_LNG:
-                       case TYPE_DBL:
-                               M_LST_IMM(iptr->val.l, REG_ITMP1, 0);
+                               M_IST_IMM(iptr->sx.s23.s2.constval & 0xffffffff, REG_ITMP1, 0);
+                               M_IST_IMM(((s4)iptr->sx.s23.s2.constval) >> 31, REG_ITMP1, 4);
                                break;
+                       default:
+                               assert(0);
                        }
                        break;
 
                case ICMD_GETFIELD:   /* .., objectref.  ==> ..., value               */
-                                     /* op1 = type, val.i = field offset             */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       gen_nullptr_check(s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       emit_nullpointer_check(cd, iptr, s1);
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+                               unresolved_field *uf = iptr->sx.s23.s3.uf;
+
+                               fieldtype = uf->fieldref->parseddesc.fd->type;
+
                                codegen_addpatchref(cd, PATCHER_getfield,
-                                                                       INSTRUCTION_UNRESOLVED_FIELD(iptr), 0);
+                                                                       iptr->sx.s23.s3.uf, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -2763,51 +2353,66 @@ bool codegen(jitdata *jd)
                                disp = 0;
 
                        }
-                       else
-                               disp = INSTRUCTION_RESOLVED_FIELDINFO(iptr)->offset;
+                       else {
+                               fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field;
+                               
+                               fieldtype = fi->type;
+                               disp = fi->offset;
+                       }
 
-                       switch (iptr->op1) {
+                       switch (fieldtype) {
                        case TYPE_INT:
                        case TYPE_ADR:
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                               d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                                M_ILD32(d, s1, disp);
                                break;
                        case TYPE_LNG:
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP23_PACKED);
+                               d = codegen_reg_of_dst(jd, iptr, REG_ITMP23_PACKED);
                                M_LLD32(d, s1, disp);
                                break;
                        case TYPE_FLT:
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
+                               d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
                                M_FLD32(d, s1, disp);
                                break;
                        case TYPE_DBL:                          
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
+                               d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
                                M_DLD32(d, s1, disp);
                                break;
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_PUTFIELD:   /* ..., objectref, value  ==> ...               */
-                                     /* op1 = type, val.a = field address            */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       gen_nullptr_check(s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       emit_nullpointer_check(cd, iptr, s1);
 
                        /* must be done here because of code patching */
 
-                       if (!IS_FLT_DBL_TYPE(iptr->op1)) {
-                               if (IS_2_WORD_TYPE(iptr->op1))
-                                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP23_PACKED);
+                       if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+                               unresolved_field *uf = iptr->sx.s23.s3.uf;
+
+                               fieldtype = uf->fieldref->parseddesc.fd->type;
+                       }
+                       else {
+                               fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field;
+
+                               fieldtype = fi->type;
+                       }
+
+                       if (!IS_FLT_DBL_TYPE(fieldtype)) {
+                               if (IS_2_WORD_TYPE(fieldtype))
+                                       s2 = emit_load_s2(jd, iptr, REG_ITMP23_PACKED);
                                else
-                                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
+                                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        }
                        else
-                               s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
+                               s2 = emit_load_s2(jd, iptr, REG_FTMP2);
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
-                               codegen_addpatchref(cd, PATCHER_putfield,
-                                                                       INSTRUCTION_UNRESOLVED_FIELD(iptr), 0);
+                               unresolved_field *uf = iptr->sx.s23.s3.uf;
+
+                               codegen_addpatchref(cd, PATCHER_putfield, uf, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -2816,10 +2421,13 @@ bool codegen(jitdata *jd)
                                disp = 0;
 
                        }
-                       else
-                               disp = INSTRUCTION_RESOLVED_FIELDINFO(iptr)->offset;
+                       else {
+                               fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field;
+
+                               disp = fi->offset;
+                       }
 
-                       switch (iptr->op1) {
+                       switch (fieldtype) {
                        case TYPE_INT:
                        case TYPE_ADR:
                                M_IST32(s2, s1, disp);
@@ -2838,15 +2446,18 @@ bool codegen(jitdata *jd)
 
                case ICMD_PUTFIELDCONST:  /* ..., objectref  ==> ...                  */
                                          /* val = value (in current instruction)     */
-                                         /* op1 = type, val.a = field address (in    */
                                          /* following NOP)                           */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       gen_nullptr_check(s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       emit_nullpointer_check(cd, iptr, s1);
+
+                       if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+                               unresolved_field *uf = iptr->sx.s23.s3.uf;
+
+                               fieldtype = uf->fieldref->parseddesc.fd->type;
 
-                       if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) {
                                codegen_addpatchref(cd, PATCHER_putfieldconst,
-                                                                       INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), 0);
+                                                                       uf, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -2856,18 +2467,25 @@ bool codegen(jitdata *jd)
 
                        }
                        else
-                               disp = INSTRUCTION_RESOLVED_FIELDINFO(iptr + 1)->offset;
+                       {
+                               fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field;
+
+                               fieldtype = fi->type;
+                               disp = fi->offset;
+                       }
+
 
-                       switch (iptr[1].op1) {
+                       switch (fieldtype) {
                        case TYPE_INT:
-                       case TYPE_FLT:
                        case TYPE_ADR:
-                               M_IST32_IMM(iptr->val.i, s1, disp);
+                               M_IST32_IMM(iptr->sx.s23.s2.constval, s1, disp);
                                break;
                        case TYPE_LNG:
-                       case TYPE_DBL:
-                               M_LST32_IMM(iptr->val.l, s1, disp);
+                               M_IST32_IMM(iptr->sx.s23.s2.constval & 0xffffffff, s1, disp);
+                               M_IST32_IMM(((s4)iptr->sx.s23.s2.constval) >> 31, s1, disp + 4);
                                break;
+                       default:
+                               assert(0);
                        }
                        break;
 
@@ -2876,13 +2494,13 @@ bool codegen(jitdata *jd)
 
                case ICMD_ATHROW:       /* ..., objectref ==> ... (, objectref)       */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, REG_ITMP1_XPTR);
 
 #ifdef ENABLE_VERIFIER
-                       if (iptr->val.a) {
+                       if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                codegen_addpatchref(cd, PATCHER_athrow_areturn,
-                                                                       (unresolved_class *) iptr->val.a, 0);
+                                                                       iptr->sx.s23.s2.uc, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -2897,402 +2515,363 @@ bool codegen(jitdata *jd)
                        M_JMP(REG_ITMP3);
                        break;
 
-               case ICMD_INLINE_GOTO:
-
-                       M_COPY(src, iptr->dst);
-                       /* FALLTHROUGH! */
-
                case ICMD_GOTO:         /* ... ==> ...                                */
-                                       /* op1 = target JavaVM pc                     */
+               case ICMD_RET:          /* ... ==> ...                                */
 
 #if defined(ENABLE_SSA)
                        if ( ls != NULL ) {
                                last_cmd_was_goto = true;
                                /* In case of a Goto phimoves have to be inserted before the */
                                /* jump */
-                               codegen_insert_phi_moves(cd, rd, ls, bptr);
+                               codegen_insert_phi_moves(jd, bptr);
                        }
 #endif
                        M_JMP_IMM(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        ALIGNCODENOP;
                        break;
 
                case ICMD_JSR:          /* ... ==> ...                                */
-                                       /* op1 = target JavaVM pc                     */
 
-                       M_CALL_IMM(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       M_JMP_IMM(0);
+                       codegen_addreference(cd, iptr->sx.s23.s3.jsrtarget.block);
                        break;
                        
-               case ICMD_RET:          /* ... ==> ...                                */
-                                       /* op1 = local variable                       */
-
-                       var = &(rd->locals[iptr->op1][TYPE_ADR]);
-                       if (var->flags & INMEMORY) {
-                               M_ALD(REG_ITMP1, REG_SP, var->regoff * 4);
-                               M_JMP(REG_ITMP1);
-                       }
-                       else
-                               M_JMP(var->regoff);
-                       break;
-
                case ICMD_IFNULL:       /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        M_TEST(s1);
                        M_BEQ(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IFNONNULL:    /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        M_TEST(s1);
                        M_BNE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IFEQ:         /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.i = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       M_CMP_IMM(iptr->val.i, s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       M_CMP_IMM(iptr->sx.val.i, s1);
                        M_BEQ(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IFLT:         /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.i = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       M_CMP_IMM(iptr->val.i, s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       M_CMP_IMM(iptr->sx.val.i, s1);
                        M_BLT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IFLE:         /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.i = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       M_CMP_IMM(iptr->val.i, s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       M_CMP_IMM(iptr->sx.val.i, s1);
                        M_BLE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IFNE:         /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.i = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       M_CMP_IMM(iptr->val.i, s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       M_CMP_IMM(iptr->sx.val.i, s1);
                        M_BNE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IFGT:         /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.i = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       M_CMP_IMM(iptr->val.i, s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       M_CMP_IMM(iptr->sx.val.i, s1);
                        M_BGT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IFGE:         /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.i = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       M_CMP_IMM(iptr->val.i, s1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       M_CMP_IMM(iptr->sx.val.i, s1);
                        M_BGE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LEQ:       /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.l = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       if (iptr->val.l == 0) {
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       if (iptr->sx.val.l == 0) {
                                M_INTMOVE(GET_LOW_REG(s1), REG_ITMP1);
                                M_OR(GET_HIGH_REG(s1), REG_ITMP1);
                        }
                        else {
                                M_LNGMOVE(s1, REG_ITMP12_PACKED);
-                               M_XOR_IMM(iptr->val.l, REG_ITMP1);
-                               M_XOR_IMM(iptr->val.l >> 32, REG_ITMP2);
+                               M_XOR_IMM(iptr->sx.val.l, REG_ITMP1);
+                               M_XOR_IMM(iptr->sx.val.l >> 32, REG_ITMP2);
                                M_OR(REG_ITMP2, REG_ITMP1);
                        }
                        M_BEQ(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LLT:       /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.l = constant   */
 
-                       if (iptr->val.l == 0) {
+                       if (iptr->sx.val.l == 0) {
                                /* If high 32-bit are less than zero, then the 64-bits
                                   are too. */
-                               s1 = emit_load_s1_high(jd, iptr, src, REG_ITMP2);
+                               s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
                                M_CMP_IMM(0, s1);
                                M_BLT(0);
                        }
                        else {
-                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                               M_CMP_IMM(iptr->val.l >> 32, GET_HIGH_REG(s1));
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                               M_CMP_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(s1));
                                M_BLT(0);
-                               codegen_addreference(cd, (basicblock *) iptr->target);
+                               codegen_addreference(cd, iptr->dst.block);
                                M_BGT(6 + 6);
-                               M_CMP_IMM32(iptr->val.l, GET_LOW_REG(s1));
+                               M_CMP_IMM32(iptr->sx.val.l, GET_LOW_REG(s1));
                                M_BB(0);
                        }                       
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LLE:       /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.l = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       M_CMP_IMM(iptr->val.l >> 32, GET_HIGH_REG(s1));
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       M_CMP_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(s1));
                        M_BLT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        M_BGT(6 + 6);
-                       M_CMP_IMM32(iptr->val.l, GET_LOW_REG(s1));
+                       M_CMP_IMM32(iptr->sx.val.l, GET_LOW_REG(s1));
                        M_BBE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LNE:       /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.l = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       if (iptr->val.l == 0) {
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       if (iptr->sx.val.l == 0) {
                                M_INTMOVE(GET_LOW_REG(s1), REG_ITMP1);
                                M_OR(GET_HIGH_REG(s1), REG_ITMP1);
                        }
                        else {
                                M_LNGMOVE(s1, REG_ITMP12_PACKED);
-                               M_XOR_IMM(iptr->val.l, REG_ITMP1);
-                               M_XOR_IMM(iptr->val.l >> 32, REG_ITMP2);
+                               M_XOR_IMM(iptr->sx.val.l, REG_ITMP1);
+                               M_XOR_IMM(iptr->sx.val.l >> 32, REG_ITMP2);
                                M_OR(REG_ITMP2, REG_ITMP1);
                        }
                        M_BNE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LGT:       /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.l = constant   */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                       M_CMP_IMM(iptr->val.l >> 32, GET_HIGH_REG(s1));
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       M_CMP_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(s1));
                        M_BGT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        M_BLT(6 + 6);
-                       M_CMP_IMM32(iptr->val.l, GET_LOW_REG(s1));
+                       M_CMP_IMM32(iptr->sx.val.l, GET_LOW_REG(s1));
                        M_BA(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LGE:       /* ..., value ==> ...                         */
-                                       /* op1 = target JavaVM pc, val.l = constant   */
 
-                       if (iptr->val.l == 0) {
+                       if (iptr->sx.val.l == 0) {
                                /* If high 32-bit are greater equal zero, then the
                                   64-bits are too. */
-                               s1 = emit_load_s1_high(jd, iptr, src, REG_ITMP2);
+                               s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
                                M_CMP_IMM(0, s1);
                                M_BGE(0);
                        }
                        else {
-                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
-                               M_CMP_IMM(iptr->val.l >> 32, GET_HIGH_REG(s1));
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                               M_CMP_IMM(iptr->sx.val.l >> 32, GET_HIGH_REG(s1));
                                M_BGT(0);
-                               codegen_addreference(cd, (basicblock *) iptr->target);
+                               codegen_addreference(cd, iptr->dst.block);
                                M_BLT(6 + 6);
-                               M_CMP_IMM32(iptr->val.l, GET_LOW_REG(s1));
+                               M_CMP_IMM32(iptr->sx.val.l, GET_LOW_REG(s1));
                                M_BAE(0);
                        }
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_ICMPEQ:    /* ..., value, value ==> ...                  */
                case ICMD_IF_ACMPEQ:    /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BEQ(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LCMPEQ:    /* ..., value, value ==> ...                  */
-                                       /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
                        M_INTMOVE(s1, REG_ITMP1);
                        M_XOR(s2, REG_ITMP1);
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP2);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP3);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        M_INTMOVE(s1, REG_ITMP2);
                        M_XOR(s2, REG_ITMP2);
                        M_OR(REG_ITMP1, REG_ITMP2);
                        M_BEQ(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_ICMPNE:    /* ..., value, value ==> ...                  */
                case ICMD_IF_ACMPNE:    /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BNE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LCMPNE:    /* ..., value, value ==> ...                  */
-                                       /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
                        M_INTMOVE(s1, REG_ITMP1);
                        M_XOR(s2, REG_ITMP1);
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP2);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP3);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        M_INTMOVE(s1, REG_ITMP2);
                        M_XOR(s2, REG_ITMP2);
                        M_OR(REG_ITMP1, REG_ITMP2);
                        M_BNE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_ICMPLT:    /* ..., value, value ==> ...                  */
-                                       /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BLT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LCMPLT:    /* ..., value, value ==> ...                  */
-                                   /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BLT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
+                       codegen_addreference(cd, iptr->dst.block);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
                        M_BGT(2 + 6);
                        M_CMP(s2, s1);
                        M_BB(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_ICMPGT:    /* ..., value, value ==> ...                  */
-                                       /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BGT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LCMPGT:    /* ..., value, value ==> ...                  */
-                                /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BGT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
+                       codegen_addreference(cd, iptr->dst.block);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
                        M_BLT(2 + 6);
                        M_CMP(s2, s1);
                        M_BA(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_ICMPLE:    /* ..., value, value ==> ...                  */
-                                       /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BLE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LCMPLE:    /* ..., value, value ==> ...                  */
-                                       /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BLT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
+                       codegen_addreference(cd, iptr->dst.block);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
                        M_BGT(2 + 6);
                        M_CMP(s2, s1);
                        M_BBE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_ICMPGE:    /* ..., value, value ==> ...                  */
-                                       /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BGE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
                case ICMD_IF_LCMPGE:    /* ..., value, value ==> ...                  */
-                                   /* op1 = target JavaVM pc                     */
 
-                       s1 = emit_load_s1_high(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP2);
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP2);
                        M_CMP(s2, s1);
                        M_BGT(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
-                       s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1);
-                       s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2);
+                       codegen_addreference(cd, iptr->dst.block);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
                        M_BLT(2 + 6);
                        M_CMP(s2, s1);
                        M_BAE(0);
-                       codegen_addreference(cd, (basicblock *) iptr->target);
+                       codegen_addreference(cd, iptr->dst.block);
                        break;
 
 
                case ICMD_IRETURN:      /* ..., retvalue ==> ...                      */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_RESULT);
+                       REPLACEMENT_POINT_RETURN(cd, iptr);
+                       s1 = emit_load_s1(jd, iptr, REG_RESULT);
                        M_INTMOVE(s1, REG_RESULT);
                        goto nowperformreturn;
 
                case ICMD_LRETURN:      /* ..., retvalue ==> ...                      */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_RESULT_PACKED);
+                       REPLACEMENT_POINT_RETURN(cd, iptr);
+                       s1 = emit_load_s1(jd, iptr, REG_RESULT_PACKED);
                        M_LNGMOVE(s1, REG_RESULT_PACKED);
                        goto nowperformreturn;
 
                case ICMD_ARETURN:      /* ..., retvalue ==> ...                      */
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_RESULT);
+                       REPLACEMENT_POINT_RETURN(cd, iptr);
+                       s1 = emit_load_s1(jd, iptr, REG_RESULT);
                        M_INTMOVE(s1, REG_RESULT);
 
 #ifdef ENABLE_VERIFIER
-                       if (iptr->val.a) {
+                       if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                codegen_addpatchref(cd, PATCHER_athrow_areturn,
-                                                                       (unresolved_class *) iptr->val.a, 0);
+                                                                       iptr->sx.s23.s2.uc, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -3304,40 +2883,23 @@ bool codegen(jitdata *jd)
                case ICMD_FRETURN:      /* ..., retvalue ==> ...                      */
                case ICMD_DRETURN:
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_FRESULT);
+                       REPLACEMENT_POINT_RETURN(cd, iptr);
+                       s1 = emit_load_s1(jd, iptr, REG_FRESULT);
                        goto nowperformreturn;
 
                case ICMD_RETURN:      /* ...  ==> ...                                */
 
+                       REPLACEMENT_POINT_RETURN(cd, iptr);
+
 nowperformreturn:
                        {
                        s4 i, p;
                        
-                       p = stackframesize;
+                       p = cd->stackframesize;
                        
 #if !defined(NDEBUG)
-                       /* call trace function */
-
-                       if (opt_verbosecall) {
-                               M_ISUB_IMM(4 + 8 + 8 + 4, REG_SP);
-
-                               emit_mov_imm_membase(cd, (s4) m, REG_SP, 0);
-
-                               emit_mov_reg_membase(cd, REG_RESULT, REG_SP, 4);
-                               emit_mov_reg_membase(cd, REG_RESULT2, REG_SP, 4 + 4);
-                               
-                               emit_fstl_membase(cd, REG_SP, 4 + 8);
-                               emit_fsts_membase(cd, REG_SP, 4 + 8 + 8);
-
-                               emit_mov_imm_reg(cd, (s4) builtin_displaymethodstop, REG_ITMP1);
-                               emit_call_reg(cd, REG_ITMP1);
-
-                               emit_mov_membase_reg(cd, REG_SP, 4, REG_RESULT);
-                               emit_mov_membase_reg(cd, REG_SP, 4 + 4, REG_RESULT2);
-
-                               emit_alu_imm_reg(cd, ALU_ADD, 4 + 8 + 8 + 4, REG_SP);
-                       }
-#endif /* !defined(NDEBUG) */
+                       emit_verbosecall_exit(jd);
+#endif
 
 #if defined(ENABLE_THREADS)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
@@ -3409,8 +2971,8 @@ nowperformreturn:
 
                        /* deallocate stack */
 
-                       if (stackframesize)
-                               M_AADD_IMM(stackframesize * 4, REG_SP);
+                       if (cd->stackframesize)
+                               M_AADD_IMM(cd->stackframesize * 4, REG_SP);
 
                        emit_ret(cd);
                        }
@@ -3419,16 +2981,15 @@ nowperformreturn:
 
                case ICMD_TABLESWITCH:  /* ..., index ==> ...                         */
                        {
-                               s4 i, l, *s4ptr;
-                               void **tptr;
+                               s4 i, l;
+                               branch_target_t *table;
 
-                               tptr = (void **) iptr->target;
+                               table = iptr->dst.table;
 
-                               s4ptr = iptr->val.a;
-                               l = s4ptr[1];                          /* low     */
-                               i = s4ptr[2];                          /* high    */
+                               l = iptr->sx.s23.s2.tablelow;
+                               i = iptr->sx.s23.s3.tablehigh;
 
-                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                                M_INTMOVE(s1, REG_ITMP1);
 
                                if (l != 0)
@@ -3437,18 +2998,18 @@ nowperformreturn:
                                i = i - l + 1;
 
                 /* range check */
-
                                M_CMP_IMM(i - 1, REG_ITMP1);
                                M_BA(0);
-                               codegen_addreference(cd, (basicblock *) tptr[0]);
+
+                               codegen_addreference(cd, table[0].block); /* default target */
 
                                /* build jump table top down and use address of lowest entry */
 
-                               tptr += i;
+                               table += i;
 
                                while (--i >= 0) {
-                                       dseg_addtarget(cd, (basicblock *) tptr[0]); 
-                                       --tptr;
+                                       dseg_add_target(cd, table->block); 
+                                       --table;
                                }
 
                                /* length of dataseg after last dseg_addtarget is used
@@ -3464,55 +3025,49 @@ nowperformreturn:
 
                case ICMD_LOOKUPSWITCH: /* ..., key ==> ...                           */
                        {
-                               s4 i, l, val, *s4ptr;
-                               void **tptr;
+                               s4 i;
+                               lookup_target_t *lookup;
 
-                               tptr = (void **) iptr->target;
+                               lookup = iptr->dst.lookup;
 
-                               s4ptr = iptr->val.a;
-                               l = s4ptr[0];                          /* default  */
-                               i = s4ptr[1];                          /* count    */
+                               i = iptr->sx.s23.s2.lookupcount;
                        
                                MCODECHECK((i<<2)+8);
-                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                while (--i >= 0) {
-                                       s4ptr += 2;
-                                       ++tptr;
-
-                                       val = s4ptr[0];
-                                       M_CMP_IMM(val, s1);
+                                       M_CMP_IMM(lookup->value, s1);
                                        M_BEQ(0);
-                                       codegen_addreference(cd, (basicblock *) tptr[0]); 
+                                       codegen_addreference(cd, lookup->target.block);
+                                       lookup++;
                                }
 
                                M_JMP_IMM(0);
                        
-                               tptr = (void **) iptr->target;
-                               codegen_addreference(cd, (basicblock *) tptr[0]);
+                               codegen_addreference(cd, iptr->sx.s23.s3.lookupdefault.block);
                        }
                        break;
 
                case ICMD_BUILTIN:      /* ..., [arg1, [arg2 ...]] ==> ...            */
-                                       /* op1 = arg count val.a = builtintable entry */
 
-                       bte = iptr->val.a;
+                       bte = iptr->sx.s23.s3.bte;
                        md = bte->md;
                        goto gen_method;
 
                case ICMD_INVOKESTATIC: /* ..., [arg1, [arg2 ...]] ==> ...            */
-                                       /* op1 = arg count, val.a = method pointer    */
 
                case ICMD_INVOKESPECIAL:/* ..., objectref, [arg1, [arg2 ...]] ==> ... */
                case ICMD_INVOKEVIRTUAL:/* op1 = arg count, val.a = method pointer    */
                case ICMD_INVOKEINTERFACE:
 
+                       REPLACEMENT_POINT_INVOKE(cd, iptr);
+
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
-                               md = INSTRUCTION_UNRESOLVED_METHOD(iptr)->methodref->parseddesc.md;
+                               md = iptr->sx.s23.s3.um->methodref->parseddesc.md;
                                lm = NULL;
                        }
                        else {
-                               lm = INSTRUCTION_RESOLVED_METHODINFO(iptr);
+                               lm = iptr->sx.s23.s3.fmiref->p.method;
                                md = lm->parseddesc;
                        }
 
@@ -3523,20 +3078,23 @@ gen_method:
 
                        /* copy arguments to registers or stack location                  */
 
-                       for (s3 = s3 - 1; s3 >= 0; s3--, src = src->prev) {
-                               if (src->varkind == ARGVAR)
+                       for (s3 = s3 - 1; s3 >= 0; s3--) {
+                               var = VAR(iptr->sx.s23.s2.args[s3]);
+         
+                               /* Already Preallocated (ARGVAR) ? */
+                               if (var->flags & PREALLOC)
                                        continue;
-                               if (IS_INT_LNG_TYPE(src->type)) {
+                               if (IS_INT_LNG_TYPE(var->type)) {
                                        if (!md->params[s3].inmemory) {
                                                log_text("No integer argument registers available!");
                                                assert(0);
 
                                        } else {
-                                               if (IS_2_WORD_TYPE(src->type)) {
-                                                       d = emit_load_s1(jd, iptr, src, REG_ITMP12_PACKED);
+                                               if (IS_2_WORD_TYPE(var->type)) {
+                                                       d = emit_load(jd, iptr, var, REG_ITMP12_PACKED);
                                                        M_LST(d, REG_SP, md->params[s3].regoff * 4);
                                                } else {
-                                                       d = emit_load_s1(jd, iptr, src, REG_ITMP1);
+                                                       d = emit_load(jd, iptr, var, REG_ITMP1);
                                                        M_IST(d, REG_SP, md->params[s3].regoff * 4);
                                                }
                                        }
@@ -3544,12 +3102,12 @@ gen_method:
                                } else {
                                        if (!md->params[s3].inmemory) {
                                                s1 = rd->argfltregs[md->params[s3].regoff];
-                                               d = emit_load_s1(jd, iptr, src, s1);
+                                               d = emit_load(jd, iptr, var, s1);
                                                M_FLTMOVE(d, s1);
 
                                        } else {
-                                               d = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                                               if (IS_2_WORD_TYPE(src->type))
+                                               d = emit_load(jd, iptr, var, REG_FTMP1);
+                                               if (IS_2_WORD_TYPE(var->type))
                                                        M_DST(d, REG_SP, md->params[s3].regoff * 4);
                                                else
                                                        M_FST(d, REG_SP, md->params[s3].regoff * 4);
@@ -3565,9 +3123,8 @@ gen_method:
                                M_MOV_IMM(disp, REG_ITMP1);
                                M_CALL(REG_ITMP1);
 
-                               /* if op1 == true, we need to check for an exception */
 
-                               if (iptr->op1 == true) {
+                               if (INSTRUCTION_MUST_CHECK(iptr)) {
                                        M_TEST(REG_RESULT);
                                        M_BEQ(0);
                                        codegen_add_fillinstacktrace_ref(cd);
@@ -3584,7 +3141,7 @@ gen_method:
 
                        case ICMD_INVOKESTATIC:
                                if (lm == NULL) {
-                                       unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr);
+                                       unresolved_method *um = iptr->sx.s23.s3.um;
 
                                        codegen_addpatchref(cd, PATCHER_invokestatic_special,
                                                                                um, 0);
@@ -3607,10 +3164,10 @@ gen_method:
 
                        case ICMD_INVOKEVIRTUAL:
                                M_ALD(REG_ITMP1, REG_SP, 0 * 4);
-                               gen_nullptr_check(REG_ITMP1);
+                               emit_nullpointer_check(cd, iptr, s1);
 
                                if (lm == NULL) {
-                                       unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr);
+                                       unresolved_method *um = iptr->sx.s23.s3.um;
 
                                        codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0);
 
@@ -3635,10 +3192,10 @@ gen_method:
 
                        case ICMD_INVOKEINTERFACE:
                                M_ALD(REG_ITMP1, REG_SP, 0 * 4);
-                               gen_nullptr_check(REG_ITMP1);
+                               emit_nullpointer_check(cd, iptr, s1);
 
                                if (lm == NULL) {
-                                       unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr);
+                                       unresolved_method *um = iptr->sx.s23.s3.um;
 
                                        codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0);
 
@@ -3667,36 +3224,39 @@ gen_method:
                                break;
                        }
 
+                       /* store size of call code in replacement point */
+
+                       REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr);
+
                        /* d contains return type */
 
                        if (d != TYPE_VOID) {
 #if defined(ENABLE_SSA)
-                               if ((ls == NULL) || (iptr->dst->varkind != TEMPVAR) ||
-                                       (ls->lifetime[-iptr->dst->varnum-1].type != -1)) 
+                               if ((ls == NULL) || (!IS_TEMPVAR_INDEX(iptr->dst.varindex)) ||
+                                       (ls->lifetime[-iptr->dst.varindex-1].type != -1)) 
                                        /* a "living" stackslot */
 #endif
                                {
-                                       if (IS_INT_LNG_TYPE(iptr->dst->type)) {
-                                               if (IS_2_WORD_TYPE(iptr->dst->type)) {
-                                                       s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT_PACKED);
+                                       if (IS_INT_LNG_TYPE(d)) {
+                                               if (IS_2_WORD_TYPE(d)) {
+                                                       s1 = codegen_reg_of_dst(jd, iptr, REG_RESULT_PACKED);
                                                        M_LNGMOVE(REG_RESULT_PACKED, s1);
                                                }
                                                else {
-                                                       s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT);
+                                                       s1 = codegen_reg_of_dst(jd, iptr, REG_RESULT);
                                                        M_INTMOVE(REG_RESULT, s1);
                                                }
                                        }
                                        else {
-                                               s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL);
+                                               s1 = codegen_reg_of_dst(jd, iptr, REG_NULL);
                                        }
-                                       emit_store(jd, iptr, iptr->dst, s1);
+                                       emit_store_dst(jd, iptr, s1);
                                }
                        }
                        break;
 
 
                case ICMD_CHECKCAST:  /* ..., objectref ==> ..., objectref            */
-                                     /* op1:   0 == array, 1 == class                */
                                      /* val.a: (classinfo*) superclass               */
 
                        /*  superclass is an interface:
@@ -3712,20 +3272,20 @@ gen_method:
                         *         super->vftbl->diffval));
                         */
 
-                       if (iptr->op1 == 1) {
+                       if (!(iptr->flags.bits & INS_FLAG_ARRAY)) {
                                /* object type cast-check */
 
                                classinfo *super;
                                vftbl_t   *supervftbl;
                                s4         superindex;
 
-                               super = (classinfo *) iptr->val.a;
-
-                               if (!super) {
+                               if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+                                       super = NULL;
                                        superindex = 0;
                                        supervftbl = NULL;
-
-                               } else {
+                               }
+                               else {
+                                       super = iptr->sx.s23.s3.c.cls;
                                        superindex = super->index;
                                        supervftbl = super->vftbl;
                                }
@@ -3733,7 +3293,7 @@ gen_method:
 #if defined(ENABLE_THREADS)
                                codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
 #endif
-                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                /* calculate interface checkcast code size */
 
@@ -3784,7 +3344,7 @@ gen_method:
                                        M_BEQ(5 + (opt_showdisassemble ? 5 : 0) + 6 + 6 + s2 + 5 + s3);
 
                                        codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags,
-                                                                               (constant_classref *) iptr->target, 0);
+                                                                               iptr->sx.s23.s3.c.ref, 0);
 
                                        if (opt_showdisassemble) {
                                                M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -3808,7 +3368,7 @@ gen_method:
                                        if (super == NULL) {
                                                codegen_addpatchref(cd,
                                                                                        PATCHER_checkcast_instanceof_interface,
-                                                                                       (constant_classref *) iptr->target,
+                                                                                       iptr->sx.s23.s3.c.ref,
                                                                                        0);
 
                                                if (opt_showdisassemble) {
@@ -3845,7 +3405,7 @@ gen_method:
 
                                        if (super == NULL) {
                                                codegen_addpatchref(cd, PATCHER_checkcast_class,
-                                                                                       (constant_classref *) iptr->target,
+                                                                                       iptr->sx.s23.s3.c.ref,
                                                                                        0);
 
                                                if (opt_showdisassemble) {
@@ -3882,41 +3442,40 @@ gen_method:
                                        codegen_add_classcastexception_ref(cd, s1);
                                }
 
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP3);
+                               d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
                        }
                        else {
                                /* array type cast-check */
 
-                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP2);
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP2);
                                M_AST(s1, REG_SP, 0 * 4);
 
-                               if (iptr->val.a == NULL) {
+                               if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                        codegen_addpatchref(cd, PATCHER_builtin_arraycheckcast,
-                                                                               iptr->target, 0);
+                                                                               iptr->sx.s23.s3.c.ref, 0);
 
                                        if (opt_showdisassemble) {
                                                M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
                                        }
                                }
 
-                               M_AST_IMM(iptr->val.a, REG_SP, 1 * 4);
+                               M_AST_IMM(iptr->sx.s23.s3.c.cls, REG_SP, 1 * 4);
                                M_MOV_IMM(BUILTIN_arraycheckcast, REG_ITMP3);
                                M_CALL(REG_ITMP3);
 
-                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP2);
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP2);
                                M_TEST(REG_RESULT);
                                M_BEQ(0);
                                codegen_add_classcastexception_ref(cd, s1);
 
-                               d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, s1);
+                               d = codegen_reg_of_dst(jd, iptr, s1);
                        }
 
                        M_INTMOVE(s1, d);
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult            */
-                                     /* op1:   0 == array, 1 == class                */
                                      /* val.a: (classinfo*) superclass               */
 
                        /*  superclass is an interface:
@@ -3937,13 +3496,13 @@ gen_method:
                        vftbl_t   *supervftbl;
                        s4         superindex;
 
-                       super = (classinfo *) iptr->val.a;
-
-                       if (!super) {
+                       if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+                               super = NULL;
                                superindex = 0;
                                supervftbl = NULL;
 
                        } else {
+                               super = iptr->sx.s23.s3.c.cls;
                                superindex = super->index;
                                supervftbl = super->vftbl;
                        }
@@ -3952,8 +3511,8 @@ gen_method:
                        codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
 #endif
 
-                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-                       d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s1 == d) {
                                M_INTMOVE(s1, REG_ITMP1);
                                s1 = REG_ITMP1;
@@ -3998,7 +3557,7 @@ gen_method:
                                M_BEQ(5 + (opt_showdisassemble ? 5 : 0) + 6 + 6 + s2 + 5 + s3);
 
                                codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags,
-                                                                       (constant_classref *) iptr->target, 0);
+                                                                       iptr->sx.s23.s3.c.ref, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -4022,7 +3581,7 @@ gen_method:
                                if (!super) {
                                        codegen_addpatchref(cd,
                                                                                PATCHER_checkcast_instanceof_interface,
-                                                                               (constant_classref *) iptr->target, 0);
+                                                                               iptr->sx.s23.s3.c.ref, 0);
 
                                        if (opt_showdisassemble) {
                                                M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -4063,7 +3622,7 @@ gen_method:
 
                                if (!super) {
                                        codegen_addpatchref(cd, PATCHER_instanceof_class,
-                                                                               (constant_classref *) iptr->target, 0);
+                                                                               iptr->sx.s23.s3.c.ref, 0);
 
                                        if (opt_showdisassemble) {
                                                M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -4086,37 +3645,38 @@ gen_method:
                                M_BA(5);
                                M_MOV_IMM(1, d);
                        }
-                       emit_store(jd, iptr, iptr->dst, d);
+                       emit_store_dst(jd, iptr, d);
                        }
                        break;
 
                        break;
 
                case ICMD_MULTIANEWARRAY:/* ..., cnt1, [cnt2, ...] ==> ..., arrayref  */
-                                     /* op1 = dimension, val.a = class               */
 
                        /* check for negative sizes and copy sizes to stack if necessary  */
 
-                       MCODECHECK((iptr->op1 << 1) + 64);
+                       MCODECHECK((iptr->s1.argcount << 1) + 64);
 
-                       for (s1 = iptr->op1; --s1 >= 0; src = src->prev) {
+                       for (s1 = iptr->s1.argcount; --s1 >= 0; ) {
                                /* copy SAVEDVAR sizes to stack */
+                               var = VAR(iptr->sx.s23.s2.args[s1]);
 
-                               if (src->varkind != ARGVAR) {
-                                       if (src->flags & INMEMORY) {
-                                               M_ILD(REG_ITMP1, REG_SP, src->regoff * 4);
+                               /* Already Preallocated? */
+                               if (!(var->flags & PREALLOC)) {
+                                       if (var->flags & INMEMORY) {
+                                               M_ILD(REG_ITMP1, REG_SP, var->vv.regoff * 4);
                                                M_IST(REG_ITMP1, REG_SP, (s1 + 3) * 4);
                                        }
                                        else
-                                               M_IST(src->regoff, REG_SP, (s1 + 3) * 4);
+                                               M_IST(var->vv.regoff, REG_SP, (s1 + 3) * 4);
                                }
                        }
 
                        /* is a patcher function set? */
 
-                       if (iptr->val.a == NULL) {
+                       if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                codegen_addpatchref(cd, PATCHER_builtin_multianewarray,
-                                                                       (constant_classref *) iptr->target, 0);
+                                                                       iptr->sx.s23.s3.c.ref, 0);
 
                                if (opt_showdisassemble) {
                                        M_NOP; M_NOP; M_NOP; M_NOP; M_NOP;
@@ -4126,11 +3686,11 @@ gen_method:
 
                        }
                        else
-                               disp = (ptrint) iptr->val.a;
+                               disp = (ptrint) iptr->sx.s23.s3.c.cls;
 
                        /* a0 = dimension count */
 
-                       M_IST_IMM(iptr->op1, REG_SP, 0 * 4);
+                       M_IST_IMM(iptr->s1.argcount, REG_SP, 0 * 4);
 
                        /* a1 = arraydescriptor */
 
@@ -4151,9 +3711,9 @@ gen_method:
                        M_BEQ(0);
                        codegen_add_fillinstacktrace_ref(cd);
 
-                       s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT);
+                       s1 = codegen_reg_of_dst(jd, iptr, REG_RESULT);
                        M_INTMOVE(REG_RESULT, s1);
-                       emit_store(jd, iptr, iptr->dst, s1);
+                       emit_store_dst(jd, iptr, s1);
                        break;
 
                default:
@@ -4164,11 +3724,8 @@ gen_method:
                
        } /* for instruction */
                
-       /* copy values to interface registers */
+       MCODECHECK(64);
 
-       src = bptr->outstack;
-       len = bptr->outdepth;
-       MCODECHECK(64+len);
 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
        if (!opt_lsra)
 #endif
@@ -4177,44 +3734,11 @@ gen_method:
                /* by edge splitting, in Blocks with phi moves there can only */
                /* be a goto as last command, no other Jump/Branch Command    */
                if (!last_cmd_was_goto)
-                       codegen_insert_phi_moves(cd, rd, ls, bptr);
-       } else
-#endif
-       while (src) {
-               len--;
-               if ((src->varkind != STACKVAR)) {
-                       s2 = src->type;
-                       if (IS_FLT_DBL_TYPE(s2)) {
-                               s1 = emit_load_s1(jd, iptr, src, REG_FTMP1);
-                               if (!(rd->interfaces[len][s2].flags & INMEMORY))
-                                       M_FLTMOVE(s1, rd->interfaces[len][s2].regoff);
-                               else
-                                       M_DST(s1, REG_SP, rd->interfaces[len][s2].regoff * 4);
-
-                       } else {
-                               if (IS_2_WORD_TYPE(s2))
-                                       assert(0);
-/*                                     s1 = emit_load_s1(jd, iptr, src, PACK_REGS(REG_ITMP1, REG_ITMP2)); */
-                               else
-                                       s1 = emit_load_s1(jd, iptr, src, REG_ITMP1);
-
-                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
-                                       if (IS_2_WORD_TYPE(s2))
-                                               M_LNGMOVE(s1, rd->interfaces[len][s2].regoff);
-                                       else
-                                               M_INTMOVE(s1, rd->interfaces[len][s2].regoff);
-
-                               } else {
-                                       if (IS_2_WORD_TYPE(s2))
-                                               M_LST(s1, REG_SP, rd->interfaces[len][s2].regoff * 4);
-                                       else
-                                               M_IST(s1, REG_SP, rd->interfaces[len][s2].regoff * 4);
-                               }
-                       }
-               }
-               src = src->prev;
+                       codegen_insert_phi_moves(jd, bptr);
        }
 
+#endif
+
        /* At the end of a basic block we may have to append some nops,
           because the patcher stub calling code might be longer than the
           actual instruction. So codepatching does not change the
@@ -4234,158 +3758,10 @@ gen_method:
 
        /* generate exception and patcher stubs */
 
-       {
-               exceptionref *eref;
-               patchref     *pref;
-               u8            mcode;
-               u1           *savedmcodeptr;
-               u1           *tmpmcodeptr;
-
-               savedmcodeptr = NULL;
-
-               /* generate exception stubs */
-
-               for (eref = cd->exceptionrefs; eref != NULL; eref = eref->next) {
-                       gen_resolvebranch(cd->mcodebase + eref->branchpos,
-                                                         eref->branchpos,
-                                                         cd->mcodeptr - cd->mcodebase);
-
-                       MCODECHECK(512);
-
-                       /* Check if the exception is an
-                          ArrayIndexOutOfBoundsException.  If so, move index register
-                          into REG_ITMP1. */
-
-                       if (eref->reg != -1)
-                               M_INTMOVE(eref->reg, REG_ITMP1);
-
-                       /* calcuate exception address */
-
-                       M_MOV_IMM(0, REG_ITMP2_XPC);
-                       dseg_adddata(cd);
-                       M_AADD_IMM32(eref->branchpos - 6, REG_ITMP2_XPC);
-
-                       /* move function to call into REG_ITMP3 */
-
-                       M_MOV_IMM(eref->function, REG_ITMP3);
-
-                       if (savedmcodeptr != NULL) {
-                               M_JMP_IMM((savedmcodeptr - cd->mcodeptr) - 5);
-
-                       } else {
-                               savedmcodeptr = cd->mcodeptr;
-
-                               M_ASUB_IMM(5 * 4, REG_SP);
-
-                               /* first save REG_ITMP1 so we can use it */
-
-                               M_AST(REG_ITMP1, REG_SP, 4 * 4);                /* for AIOOBE */
-
-                               M_AST_IMM(0, REG_SP, 0 * 4);
-                               dseg_adddata(cd);
-                               M_MOV(REG_SP, REG_ITMP1);
-                               M_AADD_IMM(5 * 4, REG_ITMP1);
-                               M_AST(REG_ITMP1, REG_SP, 1 * 4);
-                               M_ALD(REG_ITMP1, REG_SP, (5 + stackframesize) * 4);
-                               M_AST(REG_ITMP1, REG_SP, 2 * 4);
-                               M_AST(REG_ITMP2_XPC, REG_SP, 3 * 4);
-
-                               M_CALL(REG_ITMP3);
-
-                               M_ALD(REG_ITMP2_XPC, REG_SP, 3 * 4);
-                               M_AADD_IMM(5 * 4, REG_SP);
-
-                               M_MOV_IMM(asm_handle_exception, REG_ITMP3);
-                               M_JMP(REG_ITMP3);
-                       }
-               }
-
-
-               /* generate code patching stub call code */
-
-               for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
-                       /* check code segment size */
-
-                       MCODECHECK(512);
+       emit_exception_stubs(jd);
+       emit_patcher_stubs(jd);
+       REPLACEMENT_EMIT_STUBS(jd);
 
-                       /* Get machine code which is patched back in later. A
-                          `call rel32' is 5 bytes long. */
-
-                       savedmcodeptr = cd->mcodebase + pref->branchpos;
-                       mcode = *((u8 *) savedmcodeptr);
-
-                       /* patch in `call rel32' to call the following code */
-
-                       tmpmcodeptr  = cd->mcodeptr;    /* save current mcodeptr          */
-                       cd->mcodeptr = savedmcodeptr;   /* set mcodeptr to patch position */
-
-                       M_CALL_IMM(tmpmcodeptr - (savedmcodeptr + PATCHER_CALL_SIZE));
-
-                       cd->mcodeptr = tmpmcodeptr;     /* restore the current mcodeptr   */
-
-                       /* save REG_ITMP3 */
-
-                       M_PUSH(REG_ITMP3);
-
-                       /* move pointer to java_objectheader onto stack */
-
-#if defined(ENABLE_THREADS)
-                       (void) dseg_addaddress(cd, NULL);                         /* flcword    */
-                       (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */
-                       off = dseg_addaddress(cd, NULL);                          /* vftbl      */
-
-                       M_MOV_IMM(0, REG_ITMP3);
-                       dseg_adddata(cd);
-                       M_AADD_IMM(off, REG_ITMP3);
-                       M_PUSH(REG_ITMP3);
-#else
-                       M_PUSH_IMM(0);
-#endif
-
-                       /* move machine code bytes and classinfo pointer into registers */
-
-                       M_PUSH_IMM(mcode >> 32);
-                       M_PUSH_IMM(mcode);
-                       M_PUSH_IMM(pref->ref);
-                       M_PUSH_IMM(pref->patcher);
-
-                       M_MOV_IMM(asm_patcher_wrapper, REG_ITMP3);
-                       M_JMP(REG_ITMP3);
-               }
-       }
-
-       /* generate replacement-out stubs */
-
-       {
-               int i;
-
-               replacementpoint = jd->code->rplpoints;
-
-               for (i = 0; i < jd->code->rplpointcount; ++i, ++replacementpoint) {
-                       /* check code segment size */
-
-                       MCODECHECK(512);
-
-                       /* note start of stub code */
-
-                       replacementpoint->outcode = (u1*) (ptrint)(cd->mcodeptr - cd->mcodebase);
-
-                       /* make machine code for patching */
-
-                       disp = (ptrint)(replacementpoint->outcode - replacementpoint->pc) - 5;
-                       replacementpoint->mcode = 0xe9 | ((u8)disp << 8);
-
-                       /* push address of `rplpoint` struct */
-                       
-                       M_PUSH_IMM(replacementpoint);
-
-                       /* jump to replacement function */
-
-                       M_PUSH_IMM(asm_replacement_out);
-                       M_RET;
-               }
-       }
-       
        codegen_finish(jd);
 
        /* everything's ok */
@@ -4394,13 +3770,18 @@ gen_method:
 }
 
 #if defined(ENABLE_SSA)
-void codegen_insert_phi_moves(codegendata *cd, registerdata *rd, lsradata *ls, basicblock *bptr) {
+void codegen_insert_phi_moves(jitdata *jd, basicblock *bptr) {
        /* look for phi moves */
        int t_a,s_a,i, type;
        int t_lt, s_lt; /* lifetime indices of phi_moves */
-       bool t_inmemory, s_inmemory;
        s4 t_regoff, s_regoff, s_flags, t_flags;
+       codegendata *cd;
+       lsradata *ls;
+
        MCODECHECK(512);
+
+       ls = jd->ls;
+       cd = jd->cd;
        
        /* Moves from phi functions with highest indices have to be */
        /* inserted first, since this is the order as is used for   */
@@ -4410,68 +3791,70 @@ void codegen_insert_phi_moves(codegendata *cd, registerdata *rd, lsradata *ls, b
                s_a = ls->phi_moves[bptr->nr][i][1];
 #if defined(SSA_DEBUG_VERBOSE)
                if (compileverbose)
-                       printf("BB %3i Move %3i <- %3i ",bptr->nr,t_a,s_a);
+                       printf("BB %3i Move %3i <- %3i ", bptr->nr, t_a, s_a);
 #endif
                if (t_a >= 0) {
                        /* local var lifetimes */
                        t_lt = ls->maxlifetimes + t_a;
                        type = ls->lifetime[t_lt].type;
-               } else {
+               }
+               else {
                        t_lt = -t_a-1;
                        type = ls->lifetime[t_lt].local_ss->s->type;
                        /* stackslot lifetime */
                }
+
                if (type == -1) {
 #if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose)
-                       printf("...returning - phi lifetimes where joined\n");
+                       if (compileverbose)
+                               printf("...returning - phi lifetimes where joined\n");
 #endif
                        return;
                }
+
                if (s_a >= 0) {
                        /* local var lifetimes */
                        s_lt = ls->maxlifetimes + s_a;
                        type = ls->lifetime[s_lt].type;
-               } else {
+               }
+               else {
                        s_lt = -s_a-1;
                        type = ls->lifetime[s_lt].type;
                        /* stackslot lifetime */
                }
+
                if (type == -1) {
 #if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose)
-                       printf("...returning - phi lifetimes where joined\n");
+                       if (compileverbose)
+                               printf("...returning - phi lifetimes where joined\n");
 #endif
                        return;
                }
-               if (t_a >= 0) {
 
-                       t_inmemory = rd->locals[t_a][type].flags & INMEMORY;
-                       t_flags = rd->locals[t_a][type].flags;
-                       t_regoff = rd->locals[t_a][type].regoff;
+               if (t_a >= 0) {
+                       t_flags = VAR(t_a)->flags;
+                       t_regoff = VAR(t_a)->vv.regoff;
                        
-               } else {
-                       t_inmemory = ls->lifetime[t_lt].local_ss->s->flags & INMEMORY;
+               }
+               else {
                        t_flags = ls->lifetime[t_lt].local_ss->s->flags;
                        t_regoff = ls->lifetime[t_lt].local_ss->s->regoff;
                }
 
                if (s_a >= 0) {
                        /* local var move */
-                       
-                       s_inmemory = rd->locals[s_a][type].flags & INMEMORY;
-                       s_flags = rd->locals[s_a][type].flags;
-                       s_regoff = rd->locals[s_a][type].regoff;
+                       s_flags = VAR(s_a)->flags;
+                       s_regoff = VAR(s_a)->vv.regoff;
                } else {
                        /* stackslot lifetime */
-                       s_inmemory = ls->lifetime[s_lt].local_ss->s->flags & INMEMORY;
                        s_flags = ls->lifetime[s_lt].local_ss->s->flags;
                        s_regoff = ls->lifetime[s_lt].local_ss->s->regoff;
                }
+
                if (type == -1) {
 #if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose)
-                       printf("...returning - phi lifetimes where joined\n");
+                       if (compileverbose)
+                               printf("...returning - phi lifetimes where joined\n");
 #endif
                        return;
                }
@@ -4480,16 +3863,19 @@ void codegen_insert_phi_moves(codegendata *cd, registerdata *rd, lsradata *ls, b
 
 #if defined(SSA_DEBUG_VERBOSE)
                if (compileverbose) {
-                       if ((t_inmemory) && (s_inmemory)) {
+                       if (IS_INMEMORY(t_flags) && IS_INMEMORY(s_flags)) {
                                /* mem -> mem */
                                printf("M%3i <- M%3i",t_regoff,s_regoff);
-                       } else  if (s_inmemory) {
+                       }
+                       else    if (IS_INMEMORY(s_flags)) {
                                /* mem -> reg */
                                printf("R%3i <- M%3i",t_regoff,s_regoff);
-                       } else if (t_inmemory) {
+                       }
+                       else if (IS_INMEMORY(t_flags)) {
                                /* reg -> mem */
                                printf("M%3i <- R%3i",t_regoff,s_regoff);
-                       } else {
+                       }
+                       else {
                                /* reg -> reg */
                                printf("R%3i <- R%3i",t_regoff,s_regoff);
                        }
@@ -4501,7 +3887,7 @@ void codegen_insert_phi_moves(codegendata *cd, registerdata *rd, lsradata *ls, b
 
 void cg_move(codegendata *cd, s4 type, s4 src_regoff, s4 src_flags,
                         s4 dst_regoff, s4 dst_flags) {
-       if ((dst_flags & INMEMORY) && (src_flags & INMEMORY)) {
+       if ((IS_INMEMORY(dst_flags)) && (IS_INMEMORY(src_flags))) {
                /* mem -> mem */
                if (dst_regoff != src_regoff) {
                        if (!IS_2_WORD_TYPE(type)) {
@@ -4537,10 +3923,10 @@ void cg_move(codegendata *cd, s4 type, s4 src_regoff, s4 src_flags,
                        log_text("cg_move: longs have to be in memory\n");
 /*                     assert(0); */
                }
-               if (src_flags & INMEMORY) {
+               if (IS_INMEMORY(src_flags)) {
                        /* mem -> reg */
                        emit_mov_membase_reg(cd, REG_SP, src_regoff * 4, dst_regoff);
-               } else if (dst_flags & INMEMORY) {
+               } else if (IS_INMEMORY(dst_flags)) {
                        /* reg -> mem */
                        emit_mov_reg_membase(cd, src_regoff, REG_SP, dst_regoff * 4);
                } else {
@@ -4568,7 +3954,6 @@ u1 *createcompilerstub(methodinfo *m)
 {
        u1          *s;                     /* memory to hold the stub            */
        ptrint      *d;
-       codeinfo    *code;
        codegendata *cd;
        s4           dumpsize;
 
@@ -4586,14 +3971,12 @@ u1 *createcompilerstub(methodinfo *m)
        cd = DNEW(codegendata);
        cd->mcodeptr = s;
 
-       /* Store the codeinfo pointer in the same place as in the
-          methodheader for compiled methods. */
-
-       code = code_codeinfo_new(m);
+       /* The codeinfo pointer is actually a pointer to the
+          methodinfo. This fakes a codeinfo structure. */
 
        d[0] = (ptrint) asm_call_jit_compiler;
        d[1] = (ptrint) m;
-       d[2] = (ptrint) code;
+       d[2] = (ptrint) &d[1];                                    /* fake code->m */
 
        /* code for the stub */
 
@@ -4627,11 +4010,10 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
        codegendata  *cd;
        registerdata *rd;
        methoddesc   *md;
-       s4            stackframesize;
        s4            nativeparams;
        s4            i, j;                 /* count variables                    */
        s4            t;
-       s4            s1, s2, disp;
+       s4            s1, s2;
 
        /* get required compiler data */
 
@@ -4647,23 +4029,27 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
 
        /* calculate stackframe size */
 
-       stackframesize =
+       cd->stackframesize =
                sizeof(stackframeinfo) / SIZEOF_VOID_P +
                sizeof(localref_table) / SIZEOF_VOID_P +
                1 +                             /* function pointer                   */
                4 * 4 +                         /* 4 arguments (start_native_call)    */
                nmd->memuse;
 
+    /* keep stack 16-byte aligned */
+
+       cd->stackframesize |= 0x3;
+
        /* create method header */
 
-       (void) dseg_addaddress(cd, code);                      /* CodeinfoPointer */
-       (void) dseg_adds4(cd, stackframesize * 4);             /* FrameSize       */
-       (void) dseg_adds4(cd, 0);                              /* IsSync          */
-       (void) dseg_adds4(cd, 0);                              /* IsLeaf          */
-       (void) dseg_adds4(cd, 0);                              /* IntSave         */
-       (void) dseg_adds4(cd, 0);                              /* FltSave         */
+       (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
+       (void) dseg_add_unique_s4(cd, cd->stackframesize * 4); /* FrameSize       */
+       (void) dseg_add_unique_s4(cd, 0);                      /* IsSync          */
+       (void) dseg_add_unique_s4(cd, 0);                      /* IsLeaf          */
+       (void) dseg_add_unique_s4(cd, 0);                      /* IntSave         */
+       (void) dseg_add_unique_s4(cd, 0);                      /* FltSave         */
        (void) dseg_addlinenumbertablesize(cd);
-       (void) dseg_adds4(cd, 0);                              /* ExTableSize     */
+       (void) dseg_add_unique_s4(cd, 0);                      /* ExTableSize     */
 
        /* generate native method profiling code */
 
@@ -4676,72 +4062,11 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
 
        /* calculate stackframe size for native function */
 
-       M_ASUB_IMM(stackframesize * 4, REG_SP);
+       M_ASUB_IMM(cd->stackframesize * 4, REG_SP);
 
 #if !defined(NDEBUG)
-       if (opt_verbosecall) {
-               s4 p, t;
-
-               disp = stackframesize * 4;
-
-               M_ASUB_IMM(TRACE_ARGS_NUM * 8 + 4, REG_SP);
-    
-               for (p = 0; p < md->paramcount && p < TRACE_ARGS_NUM; p++) {
-                       t = md->paramtypes[p].type;
-                       if (IS_INT_LNG_TYPE(t)) {
-                               if (IS_2_WORD_TYPE(t)) {
-                                       M_ILD(REG_ITMP1, REG_SP,
-                                                 4 + TRACE_ARGS_NUM * 8 + 4 + disp);
-                                       M_ILD(REG_ITMP2, REG_SP,
-                                                 4 + TRACE_ARGS_NUM * 8 + 4 + disp + 4);
-                                       M_IST(REG_ITMP1, REG_SP, p * 8);
-                                       M_IST(REG_ITMP2, REG_SP, p * 8 + 4);
-
-                               } else if (t == TYPE_ADR) {
-                                       M_ALD(REG_ITMP1, REG_SP,
-                                                 4 + TRACE_ARGS_NUM * 8 + 4 + disp);
-                                       M_CLR(REG_ITMP2);
-                                       M_AST(REG_ITMP1, REG_SP, p * 8);
-                                       M_AST(REG_ITMP2, REG_SP, p * 8 + 4);
-
-                               } else {
-                                       M_ILD(EAX, REG_SP, 4 + TRACE_ARGS_NUM * 8 + 4 + disp);
-                                       emit_cltd(cd);
-                                       M_IST(EAX, REG_SP, p * 8);
-                                       M_IST(EDX, REG_SP, p * 8 + 4);
-                               }
-
-                       } else {
-                               if (!IS_2_WORD_TYPE(t)) {
-                                       emit_flds_membase(cd, REG_SP,
-                                                                         4 + TRACE_ARGS_NUM * 8 + 4 + disp);
-                                       emit_fstps_membase(cd, REG_SP, p * 8);
-                                       emit_alu_reg_reg(cd, ALU_XOR, REG_ITMP2, REG_ITMP2);
-                                       M_IST(REG_ITMP2, REG_SP, p * 8 + 4);
-
-                               } else {
-                                       emit_fldl_membase(cd, REG_SP,
-                                           4 + TRACE_ARGS_NUM * 8 + 4 + disp);
-                                       emit_fstpl_membase(cd, REG_SP, p * 8);
-                               }
-                       }
-                       disp += (IS_2_WORD_TYPE(t)) ? 8 : 4;
-               }
-       
-               M_CLR(REG_ITMP1);
-               for (p = md->paramcount; p < TRACE_ARGS_NUM; p++) {
-                       M_IST(REG_ITMP1, REG_SP, p * 8);
-                       M_IST(REG_ITMP1, REG_SP, p * 8 + 4);
-               }
-
-               M_AST_IMM(m, REG_SP, TRACE_ARGS_NUM * 8);
-
-               M_MOV_IMM(builtin_trace_args, REG_ITMP1);
-               M_CALL(REG_ITMP1);
-
-               M_AADD_IMM(TRACE_ARGS_NUM * 8 + 4, REG_SP);
-       }
-#endif /* !defined(NDEBUG) */
+       emit_verbosecall_enter(jd);
+#endif
 
        /* get function address (this must happen before the stackframeinfo) */
 
@@ -4772,17 +4097,17 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
        /* prepare data structures for native function call */
 
        M_MOV(REG_SP, REG_ITMP1);
-       M_AADD_IMM(stackframesize * 4, REG_ITMP1);
+       M_AADD_IMM(cd->stackframesize * 4, REG_ITMP1);
 
        M_AST(REG_ITMP1, REG_SP, 0 * 4);
        M_IST_IMM(0, REG_SP, 1 * 4);
        dseg_adddata(cd);
 
        M_MOV(REG_SP, REG_ITMP2);
-       M_AADD_IMM(stackframesize * 4 + SIZEOF_VOID_P, REG_ITMP2);
+       M_AADD_IMM(cd->stackframesize * 4 + SIZEOF_VOID_P, REG_ITMP2);
 
        M_AST(REG_ITMP2, REG_SP, 2 * 4);
-       M_ALD(REG_ITMP3, REG_SP, stackframesize * 4);
+       M_ALD(REG_ITMP3, REG_SP, cd->stackframesize * 4);
        M_AST(REG_ITMP3, REG_SP, 3 * 4);
        M_MOV_IMM(codegen_start_native_call, REG_ITMP1);
        M_CALL(REG_ITMP1);
@@ -4797,7 +4122,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                if (!md->params[i].inmemory) {
                        /* no integer argument registers */
                } else {       /* float/double in memory can be copied like int/longs */
-                       s1 = (md->params[i].regoff + stackframesize + 1) * 4;
+                       s1 = (md->params[i].regoff + cd->stackframesize + 1) * 4;
                        s2 = nmd->params[j].regoff * 4;
 
                        M_ILD(REG_ITMP1, REG_SP, s1);
@@ -4812,11 +4137,11 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
        /* if function is static, put class into second argument */
 
        if (m->flags & ACC_STATIC)
-               M_AST_IMM((ptrint) m->class, REG_SP, 1 * 4);
+               M_AST_IMM(m->class, REG_SP, 1 * 4);
 
        /* put env into first argument */
 
-       M_AST_IMM((ptrint) _Jv_env, REG_SP, 0 * 4);
+       M_AST_IMM(_Jv_env, REG_SP, 0 * 4);
 
        /* call the native function */
 
@@ -4839,42 +4164,13 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
        }
 
 #if !defined(NDEBUG)
-    if (opt_verbosecall) {
-               /* restore return value */
-
-               if (IS_INT_LNG_TYPE(md->returntype.type)) {
-                       if (IS_2_WORD_TYPE(md->returntype.type))
-                               M_ILD(REG_RESULT2, REG_SP, 2 * 4);
-                       M_ILD(REG_RESULT, REG_SP, 1 * 4);
-       
-               } else {
-                       if (IS_2_WORD_TYPE(md->returntype.type))
-                               emit_fldl_membase(cd, REG_SP, 1 * 4);
-                       else
-                               emit_flds_membase(cd, REG_SP, 1 * 4);
-               }
-
-               M_ASUB_IMM(4 + 8 + 8 + 4, REG_SP);
-
-               M_AST_IMM((ptrint) m, REG_SP, 0);
-
-               M_IST(REG_RESULT, REG_SP, 4);
-               M_IST(REG_RESULT2, REG_SP, 4 + 4);
-
-               emit_fstl_membase(cd, REG_SP, 4 + 8);
-               emit_fsts_membase(cd, REG_SP, 4 + 8 + 8);
-
-               M_MOV_IMM(builtin_displaymethodstop, REG_ITMP1);
-               M_CALL(REG_ITMP1);
-
-               M_AADD_IMM(4 + 8 + 8 + 4, REG_SP);
-    }
-#endif /* !defined(NDEBUG) */
+       emit_verbosecall_exit(jd);
+#endif
 
        /* remove native stackframe info */
 
        M_MOV(REG_SP, REG_ITMP1);
-       M_AADD_IMM(stackframesize * 4, REG_ITMP1);
+       M_AADD_IMM(cd->stackframesize * 4, REG_ITMP1);
 
        M_AST(REG_ITMP1, REG_SP, 0 * 4);
        M_MOV_IMM(codegen_finish_native_call, REG_ITMP1);
@@ -4897,7 +4193,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                }
        }
 
-       M_AADD_IMM(stackframesize * 4, REG_SP);
+       M_AADD_IMM(cd->stackframesize * 4, REG_SP);
 
        /* check for exception */
 
@@ -4916,62 +4212,9 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
        M_JMP(REG_ITMP3);
 
 
-       /* process patcher calls **************************************************/
-
-       {
-               u1       *xcodeptr;
-               patchref *pref;
-               u8        mcode;
-               u1       *tmpmcodeptr;
-
-               for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
-                       /* Get machine code which is patched back in later. A
-                          `call rel32' is 5 bytes long. */
-
-                       xcodeptr = cd->mcodebase + pref->branchpos;
-                       mcode =  *((u8 *) xcodeptr);
-
-                       /* patch in `call rel32' to call the following code */
-
-                       tmpmcodeptr  = cd->mcodeptr;    /* save current mcodeptr          */
-                       cd->mcodeptr = xcodeptr;        /* set mcodeptr to patch position */
-
-                       M_CALL_IMM(tmpmcodeptr - (xcodeptr + PATCHER_CALL_SIZE));
+       /* generate patcher stubs */
 
-                       cd->mcodeptr = tmpmcodeptr;     /* restore the current mcodeptr   */
-
-                       /* save REG_ITMP3 */
-
-                       M_PUSH(REG_ITMP3);
-
-                       /* move pointer to java_objectheader onto stack */
-
-#if defined(ENABLE_THREADS)
-                       /* create a virtual java_objectheader */
-
-                       (void) dseg_addaddress(cd, NULL);                         /* flcword    */
-                       (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */
-                       disp = dseg_addaddress(cd, NULL);                         /* vftbl      */
-
-                       M_MOV_IMM(0, REG_ITMP3);
-                       dseg_adddata(cd);
-                       M_AADD_IMM(disp, REG_ITMP3);
-                       M_PUSH(REG_ITMP3);
-#else
-                       M_PUSH_IMM(0);
-#endif
-
-                       /* move machine code bytes and classinfo pointer onto stack */
-
-                       M_PUSH_IMM((mcode >> 32));
-                       M_PUSH_IMM(mcode);
-                       M_PUSH_IMM(pref->ref);
-                       M_PUSH_IMM(pref->patcher);
-
-                       M_MOV_IMM(asm_patcher_wrapper, REG_ITMP3);
-                       M_JMP(REG_ITMP3);
-               }
-       }
+       emit_patcher_stubs(jd);
 
        codegen_finish(jd);