/* src/vm/jit/sparc64/emit.c - SPARC code emitter functions
- 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.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 4398 2006-01-31 23:43:08Z twisti $
-
*/
#include "mm/memory.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h" /* XXX for gen_resolvebranch */
+#include "vm/builtin.h"
+#include "vm/options.h"
+
#include "vm/jit/abi.h"
#include "vm/jit/abi-asm.h"
#include "vm/jit/asmpart.h"
-#include "vm/builtin.h"
#include "vm/jit/dseg.h"
#include "vm/jit/emit-common.h"
#include "vm/jit/jit.h"
#include "vm/jit/replace.h"
-#include "vmcore/options.h"
+#include "vm/jit/sparc64/solaris/macro_rename.h"
/* how to leaf optimization in the emitted stubs?? */
#define REG_PV REG_PV_CALLEE
cd = jd->cd;
if (src->flags & INMEMORY) {
- COUNT_SPILLS;
+ COUNT_READ_SPILLS(src)
- disp = JITSTACK + src->vv.regoff * 8;
+ disp = JITSTACK + src->vv.regoff;
switch(src->type)
{
cd = jd->cd;
if (dst->flags & INMEMORY) {
- COUNT_SPILLS;
+ COUNT_WRITE_SPILLS(dst)
- disp = JITSTACK + dst->vv.regoff * 8;
-
+ disp = JITSTACK + dst->vv.regoff;
+
switch(dst->type)
{
case TYPE_INT:
if (INSTRUCTION_MUST_CHECK(iptr)) {
M_BNEZ(reg, 3);
M_NOP;
- M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_ARITHMETIC);
+ M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_ArithmeticException);
}
}
void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2)
{
if (INSTRUCTION_MUST_CHECK(iptr)) {
- M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));
+ M_ILD(REG_ITMP3, s1, OFFSET(java_array_t, size));
M_CMP(s2, REG_ITMP3);
M_XBULT(3);
M_NOP;
- M_ALD_INTERN(s2, REG_ZERO, EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS);
+ M_ALD_INTERN(s2, REG_ZERO, TRAP_ArrayIndexOutOfBoundsException);
+ }
+}
+
+
+/* emit_arraystore_check *******************************************************
+
+ Emit an ArrayStoreException check.
+
+*******************************************************************************/
+
+void emit_arraystore_check(codegendata *cd, instruction *iptr)
+{
+ if (INSTRUCTION_MUST_CHECK(iptr)) {
+ M_BNEZ(REG_RESULT_CALLER, 3);
+ M_NOP;
+ M_ALD_INTERN(REG_RESULT_CALLER, REG_ZERO, TRAP_ArrayStoreException);
}
}
}
M_NOP;
- M_ALD_INTERN(s1, REG_ZERO, EXCEPTION_HARDWARE_CLASSCAST);
+ M_ALD_INTERN(s1, REG_ZERO, TRAP_ClassCastException);
}
}
if (INSTRUCTION_MUST_CHECK(iptr)) {
M_BNEZ(reg, 3);
M_NOP;
- M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_NULLPOINTER);
+ M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_NullPointerException);
}
}
if (INSTRUCTION_MUST_CHECK(iptr)) {
M_BNEZ(REG_RESULT_CALLER, 3);
M_NOP;
- M_ALD_INTERN(REG_RESULT_CALLER, REG_ZERO, EXCEPTION_HARDWARE_EXCEPTION);
+ M_ALD_INTERN(REG_RESULT_CALLER, REG_ZERO, TRAP_CHECK_EXCEPTION);
}
}
+/* emit_trap *******************************************************************
+
+ Emit a trap instruction and return the original machine code.
+
+*******************************************************************************/
+
+uint32_t emit_trap(codegendata *cd)
+{
+ uint32_t mcode;
+
+ /* Get machine code which is patched back in later. The
+ trap is 1 instruction word long. */
+
+ mcode = *((uint32_t *) cd->mcodeptr);
+
+ M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_PATCHER);
+
+ return mcode;
+}
+
+
/* emit_patcher_stubs **********************************************************
Generates the code for the patcher stubs.
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
/* emit_verbosecall_enter ******************************************************
Generates the code for the call trace.
/* save temporary registers for leaf methods */
/* XXX no leaf optimization yet
- if (jd->isleafmethod) {
+ if (code_is_leafmethod(code)) {
for (i = 0; i < INT_TMP_CNT; i++)
M_LST(rd->tmpintregs[i], REG_SP, (2 + ARG_CNT + i) * 8);
/* restore temporary registers for leaf methods */
/* XXX no leaf optimization yet
- if (jd->isleafmethod) {
+ if (code_is_leafmethod(code)) {
for (i = 0; i < INT_TMP_CNT; i++)
M_LLD(rd->tmpintregs[i], REG_SP, (2 + ARG_CNT + i) * 8);