/* src/vm/jit/x86_64/codegen.c - machine code generator for x86_64
- 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
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "mm/memory.h"
-#include "native/jni.h"
#include "native/localref.h"
#include "native/native.h"
#include "threads/lock-common.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/statistics.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
#include "vm/jit/abi.h"
#include "vm/jit/asmpart.h"
-#include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/code.hpp"
+#include "vm/jit/codegen-common.hpp"
#include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
#include "vm/jit/linenumbertable.h"
#include "vm/jit/methodheader.h"
#include "vm/jit/parse.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/patcher-common.hpp"
#include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
#include "vm/jit/trap.h"
#if defined(ENABLE_LSRA)
# include "vm/jit/allocator/lsra.h"
#endif
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
/* codegen_emit ****************************************************************
if (IS_IMM32(iptr->sx.s23.s2.constval))
M_LST_IMM32(iptr->sx.s23.s2.constval, REG_ITMP1, 0);
else {
- M_IST_IMM(iptr->sx.s23.s2.constval, REG_ITMP1, 0);
- M_IST_IMM(iptr->sx.s23.s2.constval >> 32, REG_ITMP1, 4);
+ M_MOV_IMM(iptr->sx.s23.s2.constval, REG_ITMP2);
+ M_LST(REG_ITMP2, REG_ITMP1, 0);
}
break;
}
case TYPE_LNG:
case TYPE_ADR:
case TYPE_DBL:
- /* XXX why no check for IS_IMM32? */
- M_IST32_IMM(iptr->sx.s23.s2.constval, s1, disp);
- M_IST32_IMM(iptr->sx.s23.s2.constval >> 32, s1, disp + 4);
+ /* XXX why no check for IS_IMM32? -- probably because of the patcher */
+ M_MOV_IMM(iptr->sx.s23.s2.constval, REG_ITMP2);
+ if (disp) /* resolved, disp can never be 0 */
+ M_LST(REG_ITMP2, s1, disp);
+ else /* unresolved */
+ M_LST32(REG_ITMP2, s1, disp);
break;
}
break;
/* put env into first argument register */
- M_MOV_IMM(_Jv_env, REG_A0);
+ M_MOV_IMM(VM_get_jnienv(), REG_A0);
}
/* Call the native function. */
case TYPE_INT:
case TYPE_LNG:
case TYPE_ADR:
+ switch (md->returntype.primitivetype) {
+ case PRIMITIVETYPE_BOOLEAN:
+ M_BZEXT(REG_RESULT, REG_RESULT);
+ break;
+ case PRIMITIVETYPE_BYTE:
+ M_BSEXT(REG_RESULT, REG_RESULT);
+ break;
+ case PRIMITIVETYPE_CHAR:
+ M_CZEXT(REG_RESULT, REG_RESULT);
+ break;
+ case PRIMITIVETYPE_SHORT:
+ M_SSEXT(REG_RESULT, REG_RESULT);
+ break;
+ }
M_LST(REG_RESULT, REG_SP, 0 * 8);
break;
case TYPE_FLT: