* Bugfixes, some optimizations.
authortwisti <none@none>
Wed, 21 Sep 2005 14:59:57 +0000 (14:59 +0000)
committertwisti <none@none>
Wed, 21 Sep 2005 14:59:57 +0000 (14:59 +0000)
src/vm/jit/intrp/codegen.c
src/vm/jit/intrp/engine.c
src/vm/jit/intrp/intrp.h
src/vm/jit/intrp/java.vmg

index 1d4aa9bd935193b3646fa9771fb226c296d6eb3b..2b811939878776504bad2e770324dec6544694a4 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Christian Thalinger
             Anton Ertl
 
-   $Id: codegen.c 3180 2005-09-15 15:53:56Z twisti $
+   $Id: codegen.c 3247 2005-09-21 14:59:57Z twisti $
 
 */
 
 #include <stdio.h>
 
 #include "config.h"
+#include "vm/types.h"
 
-#include "machine-instr.h"
+#include "arch.h"
 
-#include "vm/jit/intrp/arch.h"
 #include "vm/jit/intrp/codegen.h"
-#include "vm/jit/intrp/types.h"
 
 #include "cacao/cacao.h"
 #include "native/native.h"
@@ -71,6 +70,7 @@
   codegen_addreference(cd, (basicblock *) (iptr->target), cd->mcodeptr); \
 }
 
+#define index2offset(_i) (-(_i) * SIZEOF_VOID_P)
 
 /* functions used by cacao-gen.i */
 
    parameter, but we need to pass in cd to make last_compiled
    thread-safe */
 
-void
-genarg_v(Inst **cd1, Cell v)
+void genarg_v(Inst **cd1, Cell v)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *) cd1)->mcodeptr);
        *((Cell *) *mcodepp) = v;
        (*mcodepp)++;
 }
 
-void
-genarg_i(Inst **cd1, s4 i)
+void genarg_i(Inst **cd1, s4 i)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *) cd1)->mcodeptr);
        *((Cell *) *mcodepp) = i;
        (*mcodepp)++;
 }
 
-void
-genarg_b(Inst ** cd1, s4 i)
+void genarg_b(Inst ** cd1, s4 i)
 {
   genarg_i(cd1, i);
 }
 
-void
-genarg_f(Inst ** cd1, float f)
+void genarg_f(Inst ** cd1, float f)
 {
        s4 fi;
 
@@ -109,114 +105,100 @@ genarg_f(Inst ** cd1, float f)
        genarg_i(cd1, fi);
 }
 
-void
-genarg_l(Inst ** cd1, s8 l)
+void genarg_l(Inst ** cd1, s8 l)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
-       vm_l2twoCell(l, ((Cell*)*mcodepp)[1], ((Cell*)*mcodepp)[0]);
+       Inst **mcodepp = (Inst **) &(((codegendata *) cd1)->mcodeptr);
+       vm_l2twoCell(l, ((Cell *) *mcodepp)[1], ((Cell *) *mcodepp)[0]);
        (*mcodepp) +=2;
 }
 
-void
-genarg_aRef(Inst ** cd1, java_objectheader *a)
+void genarg_aRef(Inst ** cd1, java_objectheader *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *) cd1)->mcodeptr);
        *((java_objectheader **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_aArray(Inst ** cd1, java_arrayheader *a)
+void genarg_aArray(Inst ** cd1, java_arrayheader *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *) cd1)->mcodeptr);
        *((java_arrayheader **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_aaTarget(Inst ** cd1, Inst **a)
+void genarg_aaTarget(Inst ** cd1, Inst **a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((Inst ***) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_aClass(Inst ** cd1, classinfo *a)
+void genarg_aClass(Inst ** cd1, classinfo *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((classinfo **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_acr(Inst ** cd1, constant_classref *a)
+void genarg_acr(Inst ** cd1, constant_classref *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((constant_classref **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_addr(Inst ** cd1, u1 *a)
+void genarg_addr(Inst ** cd1, u1 *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((u1 **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_af(Inst ** cd1, functionptr a)
+void genarg_af(Inst ** cd1, functionptr a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((functionptr *) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_am(Inst ** cd1, methodinfo *a)
+void genarg_am(Inst ** cd1, methodinfo *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((methodinfo **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_acell(Inst ** cd1, Cell *a)
+void genarg_acell(Inst ** cd1, Cell *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((Cell **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_ainst(Inst ** cd1, Inst *a)
+void genarg_ainst(Inst ** cd1, Inst *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((Inst **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_auf(Inst ** cd1, unresolved_field *a)
+void genarg_auf(Inst ** cd1, unresolved_field *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((unresolved_field **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_aum(Inst ** cd1, unresolved_method *a)
+void genarg_aum(Inst ** cd1, unresolved_method *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((unresolved_method **) *mcodepp) = a;
        (*mcodepp)++;
 }
 
-void
-genarg_avftbl(Inst ** cd1, vftbl_t *a)
+void genarg_avftbl(Inst ** cd1, vftbl_t *a)
 {
-       Inst **mcodepp = &(((codegendata *)cd1)->mcodeptr);
+       Inst **mcodepp = (Inst **) &(((codegendata *)cd1)->mcodeptr);
        *((vftbl_t **) *mcodepp) = a;
        (*mcodepp)++;
 }
@@ -430,63 +412,63 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                case ICMD_ILOAD:      /* ...  ==> ..., content of local variable      */
                                      /* op1 = local variable                         */
 
-                       gen_ILOAD(((Inst **)cd), iptr->op1);
+                       gen_ILOAD(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
                case ICMD_LLOAD:      /* ...  ==> ..., content of local variable      */
                                      /* op1 = local variable                         */
 
-                       gen_LLOAD(((Inst **)cd), iptr->op1);
+                       gen_LLOAD(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
                case ICMD_ALOAD:      /* ...  ==> ..., content of local variable      */
                                      /* op1 = local variable                         */
 
-                       gen_ALOAD(((Inst **)cd), iptr->op1);
+                       gen_ALOAD(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
                case ICMD_FLOAD:      /* ...  ==> ..., content of local variable      */
                                      /* op1 = local variable                         */
 
-                       gen_ILOAD(((Inst **)cd), iptr->op1);
+                       gen_ILOAD(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
                case ICMD_DLOAD:      /* ...  ==> ..., content of local variable      */
                                      /* op1 = local variable                         */
 
-                       gen_LLOAD(((Inst **)cd), iptr->op1);
+                       gen_LLOAD(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
 
                case ICMD_ISTORE:     /* ..., value  ==> ...                          */
                                      /* op1 = local variable                         */
 
-                       gen_ISTORE(((Inst **)cd), iptr->op1);
+                       gen_ISTORE(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
                case ICMD_LSTORE:     /* ..., value  ==> ...                          */
                                      /* op1 = local variable                         */
 
-                       gen_LSTORE(((Inst **)cd), iptr->op1);
+                       gen_LSTORE(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
                case ICMD_ASTORE:     /* ..., value  ==> ...                          */
                                      /* op1 = local variable                         */
 
-                       gen_ASTORE(((Inst **)cd), iptr->op1);
+                       gen_ASTORE(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
 
                case ICMD_FSTORE:     /* ..., value  ==> ...                          */
                                      /* op1 = local variable                         */
 
-                       gen_ISTORE(((Inst **)cd), iptr->op1);
+                       gen_ISTORE(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
                case ICMD_DSTORE:     /* ..., value  ==> ...                          */
                                      /* op1 = local variable                         */
 
-                       gen_LSTORE(((Inst **)cd), iptr->op1);
+                       gen_LSTORE(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
 
@@ -874,7 +856,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                case ICMD_IINC:       /* ..., value  ==> ..., value + constant        */
                                      /* op1 = variable, val.i = constant             */
 
-                       gen_IINC(((Inst **)cd), iptr->op1, iptr->val.i);
+                       gen_IINC(((Inst **)cd), index2offset(iptr->op1), iptr->val.i);
                        break;
 
 
@@ -1322,7 +1304,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                case ICMD_RET:          /* ... ==> ...                                */
                                        /* op1 = local variable                       */
 
-                       gen_RET(((Inst **)cd), iptr->op1);
+                       gen_RET(((Inst **)cd), index2offset(iptr->op1));
                        break;
 
                case ICMD_IFNULL:       /* ..., value ==> ...                         */
@@ -1547,7 +1529,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                        if (runverbose)
                                gen_TRACERETURN(((Inst **)cd));
 
-                       gen_IRETURN(((Inst **)cd), cd->maxlocals);
+                       gen_IRETURN(((Inst **)cd), index2offset(cd->maxlocals));
                        break;
 
                case ICMD_LRETURN:      /* ..., retvalue ==> ...                      */
@@ -1566,7 +1548,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                        if (runverbose)
                                gen_TRACELRETURN(((Inst **)cd));
 
-                       gen_LRETURN(((Inst **)cd), cd->maxlocals);
+                       gen_LRETURN(((Inst **)cd), index2offset(cd->maxlocals));
                        break;
 
                case ICMD_RETURN:       /* ...  ==> ...                               */
@@ -1584,7 +1566,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                        if (runverbose)
                                gen_TRACERETURN(((Inst **)cd));
 
-                       gen_RETURN(((Inst **)cd), cd->maxlocals);
+                       gen_RETURN(((Inst **)cd), index2offset(cd->maxlocals));
                        break;
 
 
@@ -1915,7 +1897,6 @@ functionptr createcompilerstub (methodinfo *m)
 
 static ffi_cif *createnativecif(methodinfo *m, methoddesc *nmd)
 {
-#if 1
        methoddesc  *md = m->parseddesc; 
        ffi_cif     *pcif = NEW(ffi_cif);
        ffi_type   **types = MNEW(ffi_type *, nmd->paramcount);
@@ -1928,24 +1909,20 @@ static ffi_cif *createnativecif(methodinfo *m, methoddesc *nmd)
 
        /* for static methods, pass class pointer */
 
-       if (m->flags & ACC_STATIC) {
+       if (m->flags & ACC_STATIC)
                *ptypes++ = &ffi_type_pointer;
-       }
 
        /* pass parameter to native function */
 
-       for (i = 0; i < md->paramcount; i++) {
+       for (i = 0; i < md->paramcount; i++)
                *ptypes++ = cacaotype2ffitype(md->paramtypes[i].type);
-       }
 
-       assert(ptypes-types == nmd->paramcount);
+       assert(ptypes - types == nmd->paramcount);
+
     if (ffi_prep_cif(pcif, FFI_DEFAULT_ABI, nmd->paramcount, cacaotype2ffitype(md->returntype.type), types) != FFI_OK)
                assert(0);
 
        return pcif;
-#else
-       return 0;
-#endif
 }
 
 
index 7784bac0072a8f89afc311ab0bd53cd7a16a84a2..9406797e98e1d2538b554105e4f930dac4927437 100644 (file)
@@ -1,11 +1,11 @@
 #include <assert.h>
 
 /* #define VM_DEBUG*/
+#define USE_spTOS
 
-#include "vm/jit/intrp/arch.h"
+#include "arch.h"
 #include "vm/jit/intrp/intrp.h"
 
-#include "asmoffsets.h"
 #include "md-abi.h"
 
 #include "cacao/cacao.h"
 #include "vm/exceptions.h"
 #include "vm/loader.h"
 #include "vm/options.h"
+#include "vm/jit/methodheader.h"
 #include "vm/jit/patcher.h"
 
 #define FFCALL 0
-#include "ffcall/avcall/avcall.h"
-#include "libffi/include/ffi.h"
+
+#if FFCALL
+# include "ffcall/avcall/avcall.h"
+#else
+# include "libffi/include/ffi.h"
+#endif
 
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-# include "machine-instr.h"
+# ifndef USE_MD_THREAD_STUFF
+#  include "machine-instr.h"
+# else
+#  include "threads/native/generic-primitives.h"
+# endif
+#endif
+
+#if !defined(STORE_ORDER_BARRIER) && !defined(USE_THREADS)
+#define STORE_ORDER_BARRIER() /* nothing */
 #endif
 
 
@@ -31,8 +44,8 @@
 #  define NEXT_INST    (*IP)
 #  define INC_IP(const_inc)    ({ ip+=(const_inc);})
 #  define DEF_CA
-#  define NEXT_P1      (ip++)
-#  define NEXT_P2      ({goto **(ip-1);})
+#  define NEXT_P1      
+#  define NEXT_P2      ({goto **(ip++);})
 #  define EXEC(XT)     ({goto *(XT);})
 
 #define NEXT ({DEF_CA NEXT_P1; NEXT_P2;})
@@ -103,18 +116,18 @@ static Cell *_global_sp = (Cell *)(stack+MAX_STACK_SIZE);
   } 
 
 #define access_local_int(_offset) \
-        ( *(Cell*)(fp - (_offset)) )
+        ( *(Cell*)(((u1 *)fp) + (_offset)) )
 
 #define access_local_ref(_offset) \
-        ( *(void **)(fp - (_offset)) )
+        ( *(void **)(((u1 *)fp) + (_offset)) )
 
 #define access_local_cell(_offset) \
-        ( *(Cell *)(fp - (_offset)) )
+        ( *(Cell *)(((u1 *)fp) + (_offset)) )
 
 #if 0
 /* !! alignment bug */
 #define access_local_long(_offset) \
-        ( *(s8 *)(fp - (_offset)) )
+        ( *(s8 *)(((u1 *)fp) + (_offset)) )
 #endif
 
 #define length_array(array)                          \
@@ -140,8 +153,11 @@ static Cell *_global_sp = (Cell *)(stack+MAX_STACK_SIZE);
 
 #define MAXLOCALS(stub) (((Cell *)stub)[1])
 
-#if !defined(STORE_ORDER_BARRIER) && !defined(USE_THREADS)
-#define STORE_ORDER_BARRIER()
+#if 0
+#define CLEARSTACK(_start, _end) \
+        do {Cell *__start=(_start); MSET(__start,0,u1,(_end)-__start); } while (0)
+#else
+#define CLEARSTACK(_start, _end)
 #endif
 
 
@@ -303,7 +319,7 @@ Inst *builtin_throw(Inst *ip, java_objectheader *o, Cell *fp, Cell **new_spp, Ce
          /* get methodinfo pointer from method header */
          methodinfo *m = *(methodinfo **) (((u1 *) f) + MethodPointer);
 
-         framesize = (*((s4 *) (((u1 *) f) + FrameSize)))/sizeof(void *);
+         framesize = (*((s4 *) (((u1 *) f) + FrameSize)));
          ex = (exceptionentry *) (((u1 *) f) + ExTableStart);
          exceptiontablelength = *((s4 *) (((u1 *) f) + ExTableSize));
 
@@ -326,14 +342,14 @@ Inst *builtin_throw(Inst *ip, java_objectheader *o, Cell *fp, Cell **new_spp, Ce
 
                  if (ip-1 >= (Inst *) ex->startpc && ip-1 < (Inst *) ex->endpc &&
                          (c == NULL || builtin_instanceof(o, c))) {
-                         *new_spp = fp - framesize - 1;
+                         *new_spp = (Cell *)(((u1 *)fp) - framesize - SIZEOF_VOID_P);
                          *new_fpp = fp;
                          return (Inst *) (ex->handlerpc);
                  }
          }
 
-         ip = (Inst *)access_local_cell(framesize+1);
-         fp = (Cell *)access_local_cell(framesize);
+         ip = (Inst *)access_local_cell(-framesize - SIZEOF_VOID_P);
+         fp = (Cell *)access_local_cell(-framesize);
   }
 
   return NULL; 
index c8b7cea27b0e0bdc2379dfa5f8053abcf315bce2..83f3ca9683ac0b9c2c6a43c50e520d93b866f845 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes:
 
-   $Id: intrp.h 3212 2005-09-19 11:30:08Z twisti $
+   $Id: intrp.h 3247 2005-09-21 14:59:57Z twisti $
 
 */
 
 
 /* #define VM_PROFILING */
 
-#include "vm/jit/intrp/arch.h"
-#include "vm/jit/intrp/types.h"
+#include "config.h"
+#include "vm/types.h"
+
+#include "arch.h"
 
 #include "vm/class.h"
 #include "vm/global.h"
 #include "vm/references.h"
 #include "vm/resolve.h"
 
+#include "libffi/include/ffi.h"
+
+
 typedef void *Inst;
-typedef ptrint Cell;
+
+#if SIZEOF_VOID_P == 8
+typedef s8 Cell;
+#else
+typedef s4 Cell;
+#endif
 
 #if 1
 #define MAYBE_UNUSED __attribute__((unused))
@@ -60,6 +70,7 @@ typedef ptrint Cell;
 #endif
 
 #if SIZEOF_VOID_P == 4
+
 typedef union {
     struct {
                u4 low;
@@ -83,17 +94,20 @@ typedef union {
                                     (hi) = _d.cells.high; \
                                 })
 
-#else /* 64-bit */
+#else /* SIZEOF_VOID_P == 4 */
+
 typedef union {
-  s8 low;
-  s8 l;
-  double d;
+       s8 low;
+       s8 l;
+       double d;
 } Double_Store;
 
 
 #define FETCH_DCELL_T(d_,lo,hi,t_)     ({ (d_) = ((Double_Store)(lo)).t_; })
 #define STORE_DCELL_T(d_,lo,hi,t_)     ({ (lo) = ((Double_Store)(d_)).low; })
-#endif /* 64-bit */
+
+#endif /* SIZEOF_VOID_P == 4 */
+
 
 #define vm_twoCell2l(hi,lo,d_)  FETCH_DCELL_T(d_,lo,hi,l);
 #define vm_twoCell2d(hi,lo,d_)  FETCH_DCELL_T(d_,lo,hi,d);
@@ -166,10 +180,13 @@ extern FILE *vm_out;
 
 void init_peeptable(void);
 Inst peephole_opt(Inst inst1, Inst inst2, Cell peeptable);
+void gen_inst(Inst **vmcodepp, Inst instr);
+
 void vm_disassemble(Inst *ip, Inst *endp, Inst vm_prim[]);
 Inst *vm_disassemble_inst(Inst *ip, Inst vm_prim[]);
 
 java_objectheader *engine(Inst *ip0, Cell * sp, Cell * fp);
+ffi_type *cacaotype2ffitype(s4 cacaotype);
 
 /* print types for disassembler and tracer */
 void printarg_ui      (u4                 ui      );
@@ -196,8 +213,8 @@ void printarg_avftbl  (vftbl_t *          avftbl  );
 void printarg_Cell    (Cell               x       );
 
 /* gen_... functions used in engine.c */
-void gen_INVOKESTATIC(Inst **ctp, Inst ** aaTarget, s4 iNargs, unresolved_method * aum);
-void gen_END(Inst **ctp);
+/* void gen_INVOKESTATIC(Inst **ctp, Inst ** aaTarget, s4 iNargs, unresolved_method * aum); */
+/* void gen_END(Inst **ctp); */
 
 void vm_uncount_block(Inst *ip);
 block_count *vm_block_insert(Inst *ip);
index dc83cb67ee879dd23b4153a57a4de9314a89e90b..7ffa89d6c701ad4314269d6ea4db230bd755dd0e 100644 (file)
@@ -124,27 +124,27 @@ LCONST ( #l -- l ) opt
 
 ACONST ( #aRef -- aRef ) opt
 
-ILOAD ( #bLocal -- vResult ) 0x15
+ILOAD ( #vLocal -- vResult ) 0x15
 {
-  vResult = access_local_int(bLocal);
+  vResult = access_local_int(vLocal);
 }
 
-LLOAD ( #bLocal -- lResult ) 0x16
+LLOAD ( #vLocal -- lResult ) 0x16
 {
-  vm_twoCell2l(access_local_cell(bLocal), access_local_cell(bLocal+1), lResult);
+  vm_twoCell2l(access_local_cell(vLocal), access_local_cell(vLocal-SIZEOF_VOID_P), lResult);
 }
 
-ALOAD ( #bLocal -- aRef ) 0x19
+ALOAD ( #vLocal -- aRef ) 0x19
 {
-  aRef = (java_objectheader *)access_local_cell(bLocal);
+  aRef = (java_objectheader *)access_local_cell(vLocal);
 }
 
-IALOAD ( aArray iIndex -- iResult ) 0x2e
+IALOAD ( aArray iIndex -- vResult ) 0x2e
 {
   CHECK_NULL_PTR(aArray);
   CHECK_OUT_OF_BOUNDS(aArray, iIndex);
   ;
-  iResult = access_array_int(aArray, iIndex);
+  vResult = access_array_int(aArray, iIndex);
 }
 
 LALOAD ( aArray iIndex -- lResult ) 0x2f
@@ -163,43 +163,43 @@ AALOAD ( aArray iIndex -- aRef ) 0x32
   aRef = access_array_addr(aArray, iIndex);
 }
 
-BALOAD ( aArray iIndex -- iResult ) 0x33
+BALOAD ( aArray iIndex -- vResult ) 0x33
 {
   CHECK_NULL_PTR(aArray);
   CHECK_OUT_OF_BOUNDS(aArray, iIndex);
   ;
-  iResult = access_array_byte(aArray, iIndex);
+  vResult = access_array_byte(aArray, iIndex);
 }
 
-CALOAD ( aArray iIndex -- iResult ) 0x34
+CALOAD ( aArray iIndex -- vResult ) 0x34
 {
   CHECK_NULL_PTR(aArray);
   CHECK_OUT_OF_BOUNDS(aArray, iIndex);
   ;
-  iResult = access_array_char(aArray, iIndex);
+  vResult = access_array_char(aArray, iIndex);
 }
 
-SALOAD ( aArray iIndex -- iResult ) 0x35
+SALOAD ( aArray iIndex -- vResult ) 0x35
 {
   CHECK_NULL_PTR(aArray);
   CHECK_OUT_OF_BOUNDS(aArray, iIndex);
   ;
-  iResult = access_array_short(aArray, iIndex);
+  vResult = access_array_short(aArray, iIndex);
 }
 
-ISTORE ( #bLocal vValue -- ) 0x36
+ISTORE ( #vLocal vValue -- ) 0x36
 {
-  access_local_int(bLocal) = vValue;
+  access_local_int(vLocal) = vValue;
 }
 
-LSTORE ( #bLocal lValue -- ) 0x37
+LSTORE ( #vLocal lValue -- ) 0x37
 {
-  vm_l2twoCell(lValue, access_local_cell(bLocal), access_local_cell(bLocal+1));
+  vm_l2twoCell(lValue, access_local_cell(vLocal), access_local_cell(vLocal-SIZEOF_VOID_P));
 }
 
-ASTORE ( #bLocal aRef -- ) 0x3a
+ASTORE ( #vLocal aRef -- ) 0x3a
 {
-  access_local_cell(bLocal) = (Cell)aRef;
+  access_local_cell(vLocal) = (Cell)aRef;
 }
 
 IASTORE ( aArray iIndex iValue -- ) 0x4f
@@ -261,14 +261,14 @@ DUP2_X2 ( vValue4 vValue3 vValue2 vValue1 -- vValue2 vValue1 vValue4 vValue3 vVa
 
 SWAP ( vValue2 vValue1 -- vValue1 vValue2 ) 0x5f
 
-IADD ( iValue1 iValue2 -- iResult ) 0x60
+IADD ( vValue1 vValue2 -- vResult ) 0x60
 {
-  iResult = iValue1 + iValue2;
+  vResult = vValue2 + vValue1;
 }
 
 LADD ( lValue1 lValue2 -- lResult ) 0x61
 {
-  lResult = lValue1 + lValue2;
+  lResult = lValue2 + lValue1;
 }
 
 FADD ( fValue1 fValue2 -- fResult ) 0x62
@@ -281,9 +281,9 @@ DADD ( dValue1 dValue2 -- dResult ) 0x63
   dResult = dValue1 + dValue2;
 }
 
-ISUB ( iValue1 iValue2 -- iResult ) 0x64
+ISUB ( vValue1 vValue2 -- vResult ) 0x64
 {
-  iResult = iValue1 - iValue2;
+  vResult = vValue1 - vValue2;
 }
 
 LSUB ( lValue1 lValue2 -- lResult ) 0x65
@@ -301,9 +301,9 @@ DSUB ( dValue1 dValue2 -- dResult ) 0x67
   dResult = dValue1 - dValue2;
 }
 
-IMUL ( iValue1 iValue2 -- iResult ) 0x68
+IMUL ( vValue1 vValue2 -- vResult ) 0x68
 {
-  iResult = iValue1 * iValue2;
+  vResult = vValue1 * vValue2;
 }
 
 LMUL ( lValue1 lValue2 -- lResult ) 0x69
@@ -407,9 +407,9 @@ DREM ( dValue1 dValue2 -- dResult ) 0x73
   dResult = builtin_drem(dValue1, dValue2);
 }
 
-INEG ( iValue -- iResult ) 0x74
+INEG ( vValue -- vResult ) 0x74
 {
-  iResult = -iValue;
+  vResult = -vValue;
 }
 
 LNEG ( lValue -- lResult ) 0x75
@@ -427,14 +427,14 @@ DNEG ( dValue -- dResult ) 0x77
   dResult = -dValue;
 }
 
-ISHL ( iValue1 iValue2 -- iResult ) 0x78
+ISHL ( vValue1 vValue2 -- vResult ) 0x78
 {
-  iResult = iValue1 << (iValue2 & 31);
+  vResult = vValue1 << (vValue2 & 31);
 }
 
-LSHL ( lValue1 iValue2 -- lResult ) 0x79
+LSHL ( lValue1 vValue2 -- lResult ) 0x79
 {
-  lResult = lValue1 << (iValue2 & 63);
+  lResult = lValue1 << (vValue2 & 63);
 }
 
 ISHR ( iValue1 iValue2 -- iResult ) 0x7a
@@ -447,19 +447,19 @@ LSHR ( lValue1 iValue2 -- lResult ) 0x7b
   lResult = lValue1 >> (iValue2 & 63);
 }
 
-IUSHR ( iValue1 iValue2 -- iResult ) 0x7c
+IUSHR ( iValue1 vValue2 -- iResult ) 0x7c
 {
-  iResult = ((unsigned) iValue1) >> (iValue2 & 31);
+  iResult = ((unsigned) iValue1) >> (vValue2 & 31);
 }
 
-LUSHR ( lValue1 iValue2 -- lResult ) 0x7d
+LUSHR ( lValue1 vValue2 -- lResult ) 0x7d
 {
-  lResult = (unsigned long long) lValue1 >> (iValue2 & 63);
+  lResult = (unsigned long long) lValue1 >> (vValue2 & 63);
 }
 
-IAND ( iValue1 iValue2 -- iResult ) 0x7e
+IAND ( vValue1 vValue2 -- vResult ) 0x7e
 {
-  iResult = iValue1 & iValue2;
+  vResult = vValue1 & vValue2;
 }
 
 LAND ( lValue1 lValue2 -- lResult ) 0x7f
@@ -467,9 +467,9 @@ LAND ( lValue1 lValue2 -- lResult ) 0x7f
   lResult = lValue1 & lValue2;
 }
 
-IOR ( iValue1 iValue2 -- iResult ) 0x80
+IOR ( vValue1 vValue2 -- vResult ) 0x80
 {
-  iResult = iValue1 | iValue2;
+  vResult = vValue1 | vValue2;
 }
 
 LOR ( lValue1 lValue2 -- lResult ) 0x81
@@ -477,9 +477,9 @@ LOR ( lValue1 lValue2 -- lResult ) 0x81
   lResult = lValue1 | lValue2;
 }
 
-IXOR ( iValue1 iValue2 -- iResult ) 0x82
+IXOR ( vValue1 vValue2 -- vResult ) 0x82
 {
-  iResult = iValue1 ^ iValue2;
+  vResult = vValue1 ^ vValue2;
 }
 
 LXOR ( lValue1 lValue2 -- lResult ) 0x83
@@ -487,10 +487,9 @@ LXOR ( lValue1 lValue2 -- lResult ) 0x83
   lResult = lValue1 ^ lValue2;
 }
 
-IINC ( #bIndex #iConst  -- ) 0x84
+IINC ( #vOffset #iConst  -- ) 0x84
 {
-  access_local_int((unsigned)bIndex) =
-                 access_local_int((unsigned)bIndex) + iConst;
+  access_local_int(vOffset) += iConst;
 }
 
 I2L ( iValue -- lValue ) 0x85
@@ -569,19 +568,19 @@ INT2SHORT ( iValue -- iResult ) 0x93
   iResult = (iValue << 16) >> 16; /* XXX: try "(s2)iValue" */
 }
 
-LCMP ( lValue1 lValue2 -- iResult ) 0x94
+LCMP ( lValue1 lValue2 -- vResult ) 0x94
 {
-  iResult = lValue1 < lValue2 ? -1 : lValue1 > lValue2 ? 1 : 0;
+  vResult = lValue1 < lValue2 ? -1 : lValue1 > lValue2 ? 1 : 0;
 }
 
-FCMPL ( fValue1 fValue2 -- iResult ) 0x95
+FCMPL ( fValue1 fValue2 -- vResult ) 0x95
 {
-  iResult = builtin_fcmpl(fValue1, fValue2);
+  vResult = builtin_fcmpl(fValue1, fValue2);
 }
 
-FCMPG ( fValue1 fValue2 -- iResult ) 0x96
+FCMPG ( fValue1 fValue2 -- vResult ) 0x96
 {
-  iResult = builtin_fcmpg(fValue1, fValue2);
+  vResult = builtin_fcmpg(fValue1, fValue2);
 }
 
 DCMPL ( dValue1 dValue2 -- iResult ) 0x97
@@ -730,10 +729,10 @@ JSR (  #ainstTarget -- ainstRA ) 0xa8
   SET_IP(ainstTarget);
 }
 
-RET ( #bIndex -- ) 0xa9
+RET ( #vOffset -- ) 0xa9
 {
   Inst * saved_ip;
-  saved_ip = access_local_ref((unsigned) bIndex);
+  saved_ip = access_local_ref(vOffset);
   SET_IP(saved_ip);
 }
 
@@ -787,32 +786,38 @@ LOOKUPSWITCH ( #iNpairs #addrSegment #iOffset #ainstDefault iKey -- ) 0xab
 \       stack0 ;once there is something on the stack
 \       ...
 
-IRETURN ( #iIndexFP vValue -- vResult ) 0xac
+IRETURN ( #vOffsetFP vValue -- vResult ) 0xac
 {
   Inst *new_ip;
-  new_ip = (Inst *)access_local_cell(iIndexFP + 1);
+  Cell *currentsp = sp;
+  new_ip = (Inst *)access_local_cell(vOffsetFP - SIZEOF_VOID_P);
   sp = fp;
-  fp = (Cell *)access_local_cell(iIndexFP);
+  fp = (Cell *)access_local_cell(vOffsetFP);
+  CLEARSTACK(currentsp-5, sp);
   vResult = vValue;
   SET_IP(new_ip);
 }
 
-LRETURN ( #iIndexFP lValue -- lResult ) 0xad
+LRETURN ( #vOffsetFP lValue -- lResult ) 0xad
 {
-  Inst *new_ip = (Inst *)access_local_cell(iIndexFP + 1);
+  Inst *new_ip = (Inst *)access_local_cell(vOffsetFP - SIZEOF_VOID_P);
+  Cell *currentsp = sp;
   sp = fp - 1;
-  fp = (Cell *)access_local_cell(iIndexFP);
+  fp = (Cell *)access_local_cell(vOffsetFP);
+  CLEARSTACK(currentsp-5, sp);
   lResult = lValue;
   SET_IP(new_ip);
 }
 
-RETURN ( #iIndexFP -- ) 0xb1
+RETURN ( #vOffsetFP -- ) 0xb1
 {
   Inst *new_ip;
+  Cell *currentsp = sp;
   IF_spTOS(sp[0] = spTOS);
-  new_ip = (Inst *)access_local_cell(iIndexFP + 1);
+  new_ip = (Inst *)access_local_cell(vOffsetFP - SIZEOF_VOID_P);
   sp = fp+1;
-  fp = (Cell *)access_local_cell(iIndexFP);
+  fp = (Cell *)access_local_cell(vOffsetFP);
+  CLEARSTACK(currentsp-5, sp-1);
   SET_IP(new_ip);
   IF_spTOS(spTOS = sp[0]);
 }
@@ -847,48 +852,48 @@ PUTSTATIC_LONG ( #addr #auf lValue -- ) opt
   *((s8 *) addr) = lValue;
 }
 
-GETFIELD_CELL ( #iOffset #auf aRef -- vResult ) opt
+GETFIELD_CELL ( #vOffset #auf aRef -- vResult ) opt
 {
   CHECK_NULL_PTR(aRef);
-  vResult = *((Cell *) (((u1 *)aRef) + iOffset));
+  vResult = *((Cell *) (((u1 *)aRef) + vOffset));
 }
 
-GETFIELD_INT ( #iOffset #auf aRef -- iResult ) opt
+GETFIELD_INT ( #vOffset #auf aRef -- iResult ) opt
 {
   CHECK_NULL_PTR(aRef);
-  iResult = *((s4 *) (((u1 *)aRef) + iOffset));
+  iResult = *((s4 *) (((u1 *)aRef) + vOffset));
 }
 
-GETFIELD_LONG ( #iOffset #auf aRef -- lResult ) opt
+GETFIELD_LONG ( #vOffset #auf aRef -- lResult ) opt
 {
   CHECK_NULL_PTR(aRef);
-  lResult = *((s8 *) (((u1 *)aRef) + iOffset));
+  lResult = *((s8 *) (((u1 *)aRef) + vOffset));
 }
 
 
-PUTFIELD_CELL ( #iOffset #auf aRef vValue -- ) opt
+PUTFIELD_CELL ( #vOffset #auf aRef vValue -- ) opt
 {
   CHECK_NULL_PTR(aRef);
-  *((Cell *) (((u1 *)aRef) + iOffset)) = vValue;
+  *((Cell *) (((u1 *)aRef) + vOffset)) = vValue;
 }
 
-PUTFIELD_INT ( #iOffset #auf aRef iValue -- ) opt
+PUTFIELD_INT ( #vOffset #auf aRef iValue -- ) opt
 {
   CHECK_NULL_PTR(aRef);
-  *((s4 *) (((u1 *)aRef) + iOffset)) = iValue;
+  *((s4 *) (((u1 *)aRef) + vOffset)) = iValue;
 }
 
-PUTFIELD_LONG ( #iOffset #auf aRef lValue -- ) opt
+PUTFIELD_LONG ( #vOffset #auf aRef lValue -- ) opt
 {
   CHECK_NULL_PTR(aRef);
-  *((s8 *) (((u1 *)aRef) + iOffset)) = lValue;
+  *((s8 *) (((u1 *)aRef) + vOffset)) = lValue;
 }
 
 \ !! called methods have the number of locals at offset -1.
 \ methods are always called indirectly through the codeptr in the stub 
 \   (see createcompilerstub and TRANSLATE).
 
-INVOKEVIRTUAL ( #iOffset #iNargs #aum -- acelloldfp ainstoldip ) 0xd8
+INVOKEVIRTUAL ( #vOffset #iNargs #aum -- acelloldfp ainstoldip ) 0xd8
 {
   java_objectheader *aRef = (java_objectheader *)(sp[iNargs + 1]); /* corrected for sp change by vmg */
   char *v;
@@ -896,7 +901,7 @@ INVOKEVIRTUAL ( #iOffset #iNargs #aum -- acelloldfp ainstoldip ) 0xd8
   Inst *target;
   CHECK_NULL_PTR(aRef);
   v = (char *)(aRef->vftbl);
-  stub = *(Inst ***)(v+iOffset);
+  stub = *(Inst ***)(v+vOffset);
   target = *stub;
   acelloldfp = fp;
   ainstoldip = IP;
@@ -931,7 +936,7 @@ INVOKESPECIAL ( #aaTarget #iNargs #aum -- acelloldfp ainstoldip ) 0xb7
   SET_IP(target);
 }
 
-INVOKEINTERFACE ( #iInterfaceOffset #iOffset #iNargs #aum -- acelloldfp ainstoldip ) 0xd8
+INVOKEINTERFACE ( #iInterfaceOffset #vOffset #iNargs #aum -- acelloldfp ainstoldip ) 0xd8
 {
   java_objectheader *aRef;
   char   *v, *t;
@@ -942,7 +947,7 @@ INVOKEINTERFACE ( #iInterfaceOffset #iOffset #iNargs #aum -- acelloldfp ainstold
   CHECK_NULL_PTR(aRef);
   v = (char *)(aRef->vftbl);
   t = *(char **)(v + iInterfaceOffset);
-  stub = *(Inst ***)(t+iOffset);
+  stub = *(Inst ***)(t+vOffset);
   target = *stub;
   acelloldfp = fp;
   ainstoldip = IP;
@@ -1200,7 +1205,7 @@ STORE_ORDER_BARRIER();
 IP[-3] = INST_ADDR(PUTSTATIC_CELL);
 SET_IP(IP-3);
 
-PATCHER_GETFIELD_INT ( #iOffset #auf -- )
+PATCHER_GETFIELD_INT ( #vOffset #auf -- )
 stackframeinfo sfi;
 bool result;
 global_sp = sp;
@@ -1214,7 +1219,7 @@ STORE_ORDER_BARRIER();
 IP[-3] = INST_ADDR(GETFIELD_INT);
 SET_IP(IP-3);
 
-PATCHER_GETFIELD_LONG ( #iOffset #auf -- )
+PATCHER_GETFIELD_LONG ( #vOffset #auf -- )
 stackframeinfo sfi;
 bool result;
 global_sp = sp;
@@ -1228,7 +1233,7 @@ STORE_ORDER_BARRIER();
 IP[-3] = INST_ADDR(GETFIELD_LONG);
 SET_IP(IP-3);
 
-PATCHER_GETFIELD_CELL ( #iOffset #auf -- )
+PATCHER_GETFIELD_CELL ( #vOffset #auf -- )
 stackframeinfo sfi;
 bool result;
 global_sp = sp;
@@ -1242,7 +1247,7 @@ STORE_ORDER_BARRIER();
 IP[-3] = INST_ADDR(GETFIELD_CELL);
 SET_IP(IP-3);
 
-PATCHER_PUTFIELD_INT ( #iOffset #auf -- )
+PATCHER_PUTFIELD_INT ( #vOffset #auf -- )
 stackframeinfo sfi;
 bool result;
 global_sp = sp;
@@ -1256,7 +1261,7 @@ STORE_ORDER_BARRIER();
 IP[-3] = INST_ADDR(PUTFIELD_INT);
 SET_IP(IP-3);
 
-PATCHER_PUTFIELD_LONG ( #iOffset #auf -- )
+PATCHER_PUTFIELD_LONG ( #vOffset #auf -- )
 stackframeinfo sfi;
 bool result;
 global_sp = sp;
@@ -1270,7 +1275,7 @@ STORE_ORDER_BARRIER();
 IP[-3] = INST_ADDR(PUTFIELD_LONG);
 SET_IP(IP-3);
 
-PATCHER_PUTFIELD_CELL ( #iOffset #auf -- )
+PATCHER_PUTFIELD_CELL ( #vOffset #auf -- )
 stackframeinfo sfi;
 bool result;
 global_sp = sp;
@@ -1394,7 +1399,7 @@ STORE_ORDER_BARRIER();
 IP[-4] = INST_ADDR(INVOKESPECIAL);
 SET_IP(IP-4);
 
-PATCHER_INVOKEVIRTUAL ( #iOffset #iNargs #aum -- ) 0xd8
+PATCHER_INVOKEVIRTUAL ( #vOffset #iNargs #aum -- ) 0xd8
 stackframeinfo sfi;
 bool result;
 global_sp = sp;
@@ -1408,7 +1413,7 @@ STORE_ORDER_BARRIER();
 IP[-4] = INST_ADDR(INVOKEVIRTUAL);
 SET_IP(IP-4);
 
-PATCHER_INVOKEINTERFACE ( #iInterfaceoffset #iOffset #iNargs #aum -- ) 0xd8
+PATCHER_INVOKEINTERFACE ( #iInterfaceoffset #vOffset #iNargs #aum -- ) 0xd8
 stackframeinfo sfi;
 bool result;
 global_sp = sp;
@@ -1547,17 +1552,17 @@ TRACECALL ( -- )
 functionptr f = codegen_findmethod((functionptr)(IP-1));
 methodinfo *m = ((methodinfo **) f)[-1];
 builtin_trace_args(
-       access_local_cell(0),
-       access_local_cell(1),
-       access_local_cell(2),
-       access_local_cell(3),
+       access_local_cell(0 * -SIZEOF_VOID_P),
+       access_local_cell(1 * -SIZEOF_VOID_P),
+       access_local_cell(2 * -SIZEOF_VOID_P),
+       access_local_cell(3 * -SIZEOF_VOID_P),
 #if TRACE_ARGS_NUM > 4
-       access_local_cell(4),
-       access_local_cell(5),
+       access_local_cell(4 * -SIZEOF_VOID_P),
+       access_local_cell(5 * -SIZEOF_VOID_P),
 #endif
 #if TRACE_ARGS_NUM == 8
-       access_local_cell(6),
-       access_local_cell(7),
+       access_local_cell(6 * -SIZEOF_VOID_P),
+       access_local_cell(7 * -SIZEOF_VOID_P),
 #endif
        m);