(vm/global.h): Likewise.
(emit_patcher_stubs): Align stack to 8-byte.
(emit_verbosecall_exit): Smaller optimizations.
* src/vm/jit/arm/md-abi.h (config.h): Added.
(REG_A1_A2_PACKED): Defined.
* src/vm/jit/arm/md.c: Fixed includes.
(md_codegen_get_pv_from_pc): Use vm_abort.
* src/vm/jit/arm/codegen.c: Fixed includes.
(codegen): Align stack to 8-byte.
(createnativestub): Likewise.
* src/vm/jit/arm/codegen.h (M_ADD_IMM_EXT_MUL4): Added do-while.
(M_SUB_IMM_EXT_MUL4): Likewise.
* src/vm/jit/arm/patcher.c: Fixed includes.
(patcher_wrapper): Align stack to 8-byte.
* src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Likewise.
* src/vm/jit/arm/md-abi.c: Fixed includes.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: asmpart.S 7227 2007-01-18 13:21:36Z twisti $
+ $Id: asmpart.S 7259 2007-01-30 13:58:35Z twisti $
*/
* *
*******************************************************************************/
-#define PATCHSTACKSIZE 7*4
+#define PATCHSTACKSIZE 8*4
asm_patcher_wrapper:
mov itmp3, sp /* preserve original SP in ITMP3 */
add sp, sp, #PATCHSTACKSIZE /* remove patcher stack frame */
- ldr itmp3, [sp, #-4] /* restore ITMP3 for calling method */
- ldr pc, [sp, #-12] /* jump to new patched code */
+ ldr itmp3, [sp, #-8] /* restore ITMP3 for calling method */
+ ldr pc, [sp, #-16] /* jump to new patched code */
L_asm_patcher_wrapper_exception:
mov xptr, itmp3 /* get exception */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 7244 2007-01-29 10:19:35Z twisti $
+ $Id: codegen.c 7259 2007-01-30 13:58:35Z twisti $
*/
#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/global.h"
-#include "vm/loader.h"
-#include "vm/options.h"
-#include "vm/stringlocal.h"
#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/allocator/lsra.h"
#endif
+#include "vmcore/loader.h"
+#include "vmcore/options.h"
+
/* codegen *********************************************************************
fieldtype = -1;
/* space to save used callee saved registers */
+
savedregs_num = (jd->isleafmethod) ? 0 : 1; /* space to save the LR */
savedregs_num += (INT_SAV_CNT - rd->savintreguse);
savedregs_num += (FLT_SAV_CNT - rd->savfltreguse);
+
spilledregs_num = rd->memuse;
#if defined(ENABLE_THREADS) /* space to save argument of monitor_enter */
cd->stackframesize = spilledregs_num + savedregs_num;
+ /* XXX QUICK FIX: We shouldn't align the stack in Java code, but
+ only in native stubs. */
+ /* align stack to 8-byte */
+
+ cd->stackframesize = (cd->stackframesize + 1) & ~1;
+
/* SECTION: Method Header */
/* create method header */
}
/* save return address and used callee saved registers */
+
savedregs_bitmask = 0;
+
if (!jd->isleafmethod)
savedregs_bitmask = (1<<REG_LR);
+
for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--)
savedregs_bitmask |= (1<<(rd->savintregs[i]));
+
#if !defined(NDEBUG)
for (i = FLT_SAV_CNT - 1; i >= rd->savfltreguse; i--) {
log_text("!!! CODEGEN: floating-point callee saved registers are not saved to stack (SEVERE! STACK IS MESSED UP!)");
/* TODO: floating-point */
}
#endif
- if (savedregs_bitmask) {
+
+ if (savedregs_bitmask)
M_STMFD(savedregs_bitmask, REG_SP);
- }
/* create additional stack frame for spilled variables (if necessary) */
- if (spilledregs_num) {
- M_SUB_IMM_EXT_MUL4(REG_SP, REG_SP, spilledregs_num);
- }
+
+ if ((cd->stackframesize - savedregs_num) > 0)
+ M_SUB_IMM_EXT_MUL4(REG_SP, REG_SP, cd->stackframesize - savedregs_num);
/* take arguments out of register or stack frame */
+
md = m->parseddesc;
for (i = 0, len = 0; i < md->paramcount; i++) {
s1 = md->params[i].regoff;
#endif
/* deallocate stackframe for spilled variables */
- if (spilledregs_num) {
- M_ADD_IMM_EXT_MUL4(REG_SP, REG_SP, spilledregs_num);
- }
+
+ if ((cd->stackframesize - savedregs_num) > 0)
+ M_ADD_IMM_EXT_MUL4(REG_SP, REG_SP, cd->stackframesize - savedregs_num);
/* restore callee saved registers + do return */
+
if (savedregs_bitmask) {
if (!jd->isleafmethod) {
savedregs_bitmask &= ~(1<<REG_LR);
}
/* if LR was not on stack, we need to return manually */
+
if (jd->isleafmethod)
M_MOV(REG_PC, REG_LR);
break;
sizeof(localref_table) / SIZEOF_VOID_P + /* localref_table */
nmd->memuse; /* stack arguments */
+ /* align stack to 8-byte */
+
+ cd->stackframesize = (cd->stackframesize + 1) & ~1;
+
/* create method header */
(void) dseg_add_unique_address(cd, code); /* CodeinfoPointer */
(void) dseg_add_unique_s4(cd, 0); /* ExTableSize */
/* generate stub code */
- /* TODO: don't forget ... there is a M_ADD_IMM at the end of this stub!!! */
+
M_STMFD(1<<REG_LR, REG_SP);
- if (cd->stackframesize - 1) {
- M_SUB_IMM_EXT_MUL4(REG_SP, REG_SP, cd->stackframesize - 1);
- }
+ M_SUB_IMM_EXT_MUL4(REG_SP, REG_SP, cd->stackframesize - 1);
#if !defined(NDEBUG)
if (JITDATA_HAS_FLAG_VERBOSECALL(jd))
}
#endif
- /* save integer and float argument registers */
- M_STMFD(BITMASK_ARGS | (1<<REG_IP), REG_SP);
+ /* Save integer and float argument registers (these are 4
+ registers, stack is 8-byte aligned). */
+
+ M_STMFD(BITMASK_ARGS, REG_SP);
/* TODO: floating point */
/* create native stackframe info */
- assert(IS_IMM(20 + cd->stackframesize * 4));
- M_ADD_IMM(REG_A0, REG_SP, 20 + cd->stackframesize * 4 - SIZEOF_VOID_P);
+
+ assert(IS_IMM(4*4 + cd->stackframesize * 4));
+ M_ADD_IMM(REG_A0, REG_SP, 4*4 + cd->stackframesize * 4 - SIZEOF_VOID_P);
M_MOV(REG_A1, REG_IP);
- M_ADD_IMM(REG_A2, REG_SP, 20 + cd->stackframesize * 4);
- M_LDR_INTERN(REG_A3, REG_SP, 20 + cd->stackframesize * 4 - SIZEOF_VOID_P);
+ M_ADD_IMM(REG_A2, REG_SP, 4*4 + cd->stackframesize * 4);
+ M_LDR_INTERN(REG_A3, REG_SP, 4*4 + cd->stackframesize * 4 - SIZEOF_VOID_P);
disp = dseg_add_functionptr(cd, codegen_start_native_call);
M_DSEG_BRANCH(disp);
/* recompute ip */
- /*s1 = (s4) (cd->mcodeptr - cd->mcodebase);
- M_RECOMPUTE_IP(s1);*/
- /* restore integer and float argument registers */
- M_LDMFD(BITMASK_ARGS | (1<<REG_IP), REG_SP);
+ s1 = (s4) (cd->mcodeptr - cd->mcodebase);
+ M_RECOMPUTE_IP(s1);
+
+ /* Restore integer and float argument registers (these are 4
+ registers, stack is 8-byte aligned). */
+
+ M_LDMFD(BITMASK_ARGS, REG_SP);
/* TODO: floating point */
/* copy or spill arguments to new locations */
}
/* put class into second argument register */
+
if (m->flags & ACC_STATIC) {
disp = dseg_add_address(cd, m->class);
M_DSEG_LOAD(REG_A1, disp);
}
/* put env into first argument register */
+
disp = dseg_add_address(cd, _Jv_env);
M_DSEG_LOAD(REG_A0, disp);
/* do the native function call */
- M_DSEG_BRANCH(funcdisp); /* call native method */
+
+ M_DSEG_BRANCH(funcdisp);
/* recompute ip from pc */
/* TODO: this is only needed because of the tracer ... do we
really need it? */
+
s1 = (s4) (cd->mcodeptr - cd->mcodebase);
M_RECOMPUTE_IP(s1);
/* remove native stackframe info */
/* TODO: improve this store/load */
- M_STMFD(BITMASK_RESULT | (1<<REG_IP), REG_SP);
- M_ADD_IMM(REG_A0, REG_SP, 12 + cd->stackframesize * 4 - SIZEOF_VOID_P);
+ M_STMFD(BITMASK_RESULT, REG_SP);
+
+ M_ADD_IMM(REG_A0, REG_SP, 2*4 + cd->stackframesize * 4 - SIZEOF_VOID_P);
disp = dseg_add_functionptr(cd, codegen_finish_native_call);
M_DSEG_BRANCH(disp);
+ s1 = (s4) (cd->mcodeptr - cd->mcodebase);
+ M_RECOMPUTE_IP(s1);
+
M_MOV(REG_ITMP1_XPTR, REG_RESULT);
- M_LDMFD(BITMASK_RESULT | (1<<REG_IP), REG_SP);
+ M_LDMFD(BITMASK_RESULT, REG_SP);
/* finish stub code, but do not yet return to caller */
- if (cd->stackframesize - 1)
- M_ADD_IMM_EXT_MUL4(REG_SP, REG_SP, cd->stackframesize - 1);
-
+ M_ADD_IMM_EXT_MUL4(REG_SP, REG_SP, cd->stackframesize - 1);
M_LDMFD(1<<REG_LR, REG_SP);
/* check for exception */
{
printf("===> i am going to exit after this debugging message!\n");
printf("got asm_debug(%p, %p, %p, %p)\n",(void*)a1,(void*)a2,(void*)a3,(void*)a4);
- throw_cacao_exception_exit(string_java_lang_InternalError, "leave you now");
+ vm_abort("leave you now");
}
Authors: Michael Starzinger
Christian Thalinger
- $Id: codegen.h 6596 2007-01-11 14:22:55Z twisti $
+ $Id: codegen.h 7259 2007-01-30 13:58:35Z twisti $
*/
extended immediate operations, to handle immediates lager than 8bit.
ATTENTION: the immediate is rotatet left by 2 (multiplied by 4)!!!
*/
+
#define M_ADD_IMM_EXT_MUL4(d,n,imm) \
- assert(d!=REG_PC); \
- assert((imm) >= 0 && (imm) <= 0x00ffffff); \
- M_ADD_IMM(d, n, IMM_ROTL(imm, 1)); \
- if ((imm) > 0x000000ff) M_ADD_IMM(d, d, IMM_ROTL((imm) >> 8, 5)); \
- if ((imm) > 0x0000ffff) M_ADD_IMM(d, d, IMM_ROTL((imm) >> 16, 9));
+ do { \
+ assert(d != REG_PC); \
+ assert((imm) >= 0 && (imm) <= 0x00ffffff); \
+ M_ADD_IMM(d, n, IMM_ROTL(imm, 1)); \
+ if ((imm) > 0x000000ff) M_ADD_IMM(d, d, IMM_ROTL((imm) >> 8, 5)); \
+ if ((imm) > 0x0000ffff) M_ADD_IMM(d, d, IMM_ROTL((imm) >> 16, 9)); \
+ } while (0)
+
#define M_SUB_IMM_EXT_MUL4(d,n,imm) \
- assert(d!=REG_PC); \
- assert((imm) >= 0 && (imm) <= 0x00ffffff); \
- M_SUB_IMM(d, n, IMM_ROTL(imm, 1)); \
- if ((imm) > 0x000000ff) M_SUB_IMM(d, d, IMM_ROTL((imm) >> 8, 5)); \
- if ((imm) > 0x0000ffff) M_SUB_IMM(d, d, IMM_ROTL((imm) >> 16, 9));
+ do { \
+ assert(d != REG_PC); \
+ assert((imm) >= 0 && (imm) <= 0x00ffffff); \
+ M_SUB_IMM(d, n, IMM_ROTL(imm, 1)); \
+ if ((imm) > 0x000000ff) M_SUB_IMM(d, d, IMM_ROTL((imm) >> 8, 5)); \
+ if ((imm) > 0x0000ffff) M_SUB_IMM(d, d, IMM_ROTL((imm) >> 16, 9)); \
+ } while (0)
/* ICONST/LCONST:
#include "vm/jit/arm/codegen.h"
+#include "mm/memory.h"
+
#if defined(ENABLE_THREADS)
# include "threads/native/lock.h"
#endif
#include "vm/builtin.h"
+#include "vm/global.h"
+
#include "vm/jit/asmpart.h"
#include "vm/jit/emit-common.h"
#include "vm/jit/jit.h"
cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */
- /* create stack frame */
+ /* create stack frame (align stack to 8-byte) */
- M_SUB_IMM(REG_SP, REG_SP, 7 * 4);
+ M_SUB_IMM(REG_SP, REG_SP, 8 * 4);
/* save itmp3 onto stack */
registerdata *rd;
methoddesc *md;
s4 disp;
- s4 s1;
/* get required compiler data */
M_STMFD(BITMASK_RESULT | (1<<REG_LR) | (1<<REG_IP), REG_SP);
M_SUB_IMM(REG_SP, REG_SP, (1 + 1) * 4); /* space for d[high reg] and f */
-#if defined(__ARMEL__)
- s1 = PACK_REGS(rd->argintregs[1], rd->argintregs[2]);
-#else /* defined(__ARMEB__) */
- s1 = PACK_REGS(rd->argintregs[2], rd->argintregs[1]);
-#endif
-
switch (md->returntype.type) {
case TYPE_ADR:
case TYPE_INT:
- M_INTMOVE(REG_RESULT, GET_LOW_REG(s1));
- M_MOV_IMM(GET_HIGH_REG(s1), 0);
+ M_INTMOVE(REG_RESULT, GET_LOW_REG(REG_A1_A2_PACKED));
+ M_MOV_IMM(GET_HIGH_REG(REG_A1_A2_PACKED), 0);
break;
case TYPE_LNG:
- M_LNGMOVE(REG_RESULT_PACKED, s1);
+ M_LNGMOVE(REG_RESULT_PACKED, REG_A1_A2_PACKED);
break;
case TYPE_FLT:
break;
case TYPE_DBL:
- s1 = rd->argintregs[3];
- M_INTMOVE(REG_RESULT, s1);
+ M_INTMOVE(REG_RESULT, REG_A3);
M_IST(REG_RESULT2, REG_SP, 0 * 4);
break;
}
disp = dseg_add_address(cd, m);
- M_DSEG_LOAD(rd->argintregs[0], disp);
+ M_DSEG_LOAD(REG_A0, disp);
M_LONGBRANCH(builtin_displaymethodstop);
M_ADD_IMM(REG_SP, REG_SP, (1 + 1) * 4); /* free argument stack */
/* src/vm/jit/arm/md-abi.c - functions for arm ABI
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
J. Wenninger, Institut f. Computersprachen - TU Wien
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Michael Starzinger
-
- Changes: Christian Thalinger
-
- $Id: md-abi.c 6548 2006-10-01 22:18:38Z edwin $
+ $Id: md-abi.c 7259 2007-01-30 13:58:35Z twisti $
*/
#include "vm/jit/arm/md-abi.h"
-#include "vm/descriptor.h"
#include "vm/global.h"
+
#include "vm/jit/abi.h"
+#include "vmcore/descriptor.h"
+
/* register descripton array **************************************************/
/* src/vm/jit/arm/md-abi.h - defines for arm ABI
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
J. Wenninger, Institut f. Computersprachen - TU Wien
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Michael Starzinger
-
- $Id: md-abi.h 6545 2006-09-06 21:42:42Z twisti $
+ $Id: md-abi.h 7259 2007-01-30 13:58:35Z twisti $
*/
#ifndef _MD_ABI_H
#define _MD_ABI_H
+#include "config.h"
+
/* preallocated registers *****************************************************/
# define REG_RESULT_PACKED PACK_REGS(REG_RESULT, REG_RESULT2)
# define REG_A0_A1_PACKED PACK_REGS(REG_A0, REG_A1)
+# define REG_A1_A2_PACKED PACK_REGS(REG_A1, REG_A2)
# define REG_A2_A3_PACKED PACK_REGS(REG_A2, REG_A3)
#else /* defined(__ARMEB__) */
# define REG_RESULT_PACKED PACK_REGS(REG_RESULT2, REG_RESULT)
# define REG_A0_A1_PACKED PACK_REGS(REG_A1, REG_A0)
+# define REG_A1_A2_PACKED PACK_REGS(REG_A2, REG_A1)
# define REG_A2_A3_PACKED PACK_REGS(REG_A3, REG_A2)
#endif
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Michael Starzinger
- Christian Thalinger
-
- $Id: md.c 6591 2007-01-02 19:14:25Z twisti $
+ $Id: md.c 7259 2007-01-30 13:58:35Z twisti $
*/
#include <assert.h>
-#include "vm/global.h"
#include "vm/types.h"
#include "vm/jit/arm/md-abi.h"
#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
+#include "vm/global.h"
+
#include "vm/jit/asmpart.h"
+#include "vm/jit/md.h"
/* md_init *********************************************************************
pv -= (s4) (mcode1 & 0x000000ff);
else {
/* if this happens, we got an unexpected instruction at (*ra) */
- throw_cacao_exception_exit(string_java_lang_InternalError,
- "Unable to find method: %p (instr=%x)\n",
- ra, mcode1);
+ vm_abort("Unable to find method: %p (instr=%x)", ra, mcode1);
}
/* if we have a RECOMPUTE_IP there can be more than one instruction */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: patcher.c 7231 2007-01-22 11:45:34Z twisti $
+ $Id: patcher.c 7259 2007-01-30 13:58:35Z twisti $
*/
#include "vm/builtin.h"
#include "vm/exceptions.h"
-#include "vm/field.h"
#include "vm/initialize.h"
-#include "vm/options.h"
-#include "vm/references.h"
-#include "vm/resolve.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/md.h"
#include "vm/jit/patcher.h"
+#include "vmcore/field.h"
+#include "vmcore/options.h"
+#include "vmcore/references.h"
+#include "vmcore/resolve.h"
+
#define gen_resolveload(inst,offset) \
assert((offset) >= -0x0fff && (offset) <= 0x0fff); \
/* create the stackframeinfo */
- stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 7 * 4, ra, xpc);
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 8 * 4, ra, xpc);
/* call the proper patcher function */