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"
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;
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)++;
}
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;
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;
case ICMD_RET: /* ... ==> ... */
/* op1 = local variable */
- gen_RET(((Inst **)cd), iptr->op1);
+ gen_RET(((Inst **)cd), index2offset(iptr->op1));
break;
case ICMD_IFNULL: /* ..., value ==> ... */
if (runverbose)
gen_TRACERETURN(((Inst **)cd));
- gen_IRETURN(((Inst **)cd), cd->maxlocals);
+ gen_IRETURN(((Inst **)cd), index2offset(cd->maxlocals));
break;
case ICMD_LRETURN: /* ..., retvalue ==> ... */
if (runverbose)
gen_TRACELRETURN(((Inst **)cd));
- gen_LRETURN(((Inst **)cd), cd->maxlocals);
+ gen_LRETURN(((Inst **)cd), index2offset(cd->maxlocals));
break;
case ICMD_RETURN: /* ... ==> ... */
if (runverbose)
gen_TRACERETURN(((Inst **)cd));
- gen_RETURN(((Inst **)cd), cd->maxlocals);
+ gen_RETURN(((Inst **)cd), index2offset(cd->maxlocals));
break;
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);
/* 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
}
#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
# 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;})
}
#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) \
#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
/* 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));
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;
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))
#endif
#if SIZEOF_VOID_P == 4
+
typedef union {
struct {
u4 low;
(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);
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 );
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);
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
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
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
dResult = dValue1 + dValue2;
}
-ISUB ( iValue1 iValue2 -- iResult ) 0x64
+ISUB ( vValue1 vValue2 -- vResult ) 0x64
{
- iResult = iValue1 - iValue2;
+ vResult = vValue1 - vValue2;
}
LSUB ( lValue1 lValue2 -- lResult ) 0x65
dResult = dValue1 - dValue2;
}
-IMUL ( iValue1 iValue2 -- iResult ) 0x68
+IMUL ( vValue1 vValue2 -- vResult ) 0x68
{
- iResult = iValue1 * iValue2;
+ vResult = vValue1 * vValue2;
}
LMUL ( lValue1 lValue2 -- lResult ) 0x69
dResult = builtin_drem(dValue1, dValue2);
}
-INEG ( iValue -- iResult ) 0x74
+INEG ( vValue -- vResult ) 0x74
{
- iResult = -iValue;
+ vResult = -vValue;
}
LNEG ( lValue -- lResult ) 0x75
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
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
lResult = lValue1 & lValue2;
}
-IOR ( iValue1 iValue2 -- iResult ) 0x80
+IOR ( vValue1 vValue2 -- vResult ) 0x80
{
- iResult = iValue1 | iValue2;
+ vResult = vValue1 | vValue2;
}
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
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
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
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);
}
\ 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]);
}
*((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;
Inst *target;
CHECK_NULL_PTR(aRef);
v = (char *)(aRef->vftbl);
- stub = *(Inst ***)(v+iOffset);
+ stub = *(Inst ***)(v+vOffset);
target = *stub;
acelloldfp = fp;
ainstoldip = IP;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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);