Authors: Andreas Krall
Reinhard Grafl
- $Id: asmpart.S 901 2004-01-22 19:06:00Z twisti $
+ $Id: asmpart.S 948 2004-03-07 22:12:28Z twisti $
*/
/********************* function synchronize_caches ****************************/
.ent synchronize_caches
-synchronize_caches:
+synchronize_caches:
call_pal PAL_imb /* synchronise instruction cache */
jmp zero,(ra) /* return */
.ent asm_builtin_monitorenter
asm_builtin_monitorenter:
-
ldgp gp,0(pv)
lda pv,builtin_monitorenter
beq a0,nb_monitorenter /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_monitorenter */
nb_monitorenter:
- ldq xptr,proto_java_lang_NullPointerException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_NullPointerException
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
.end asm_builtin_monitorenter
.ent asm_builtin_monitorexit
asm_builtin_monitorexit:
-
ldgp gp,0(pv)
lda pv,builtin_monitorexit
beq a0,nb_monitorexit /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_monitorexit */
nb_monitorexit:
- ldq xptr,proto_java_lang_NullPointerException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_NullPointerException
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
.end asm_builtin_monitorexit
*******************************************************************************/
.ent asm_builtin_idiv
-asm_builtin_idiv:
+asm_builtin_idiv:
ldgp gp,0(pv)
lda pv,builtin_idiv
beq a1,nb_idiv /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_idiv */
nb_idiv:
- ldq xptr,proto_java_lang_ArithmeticException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_ArithmeticException
+ ldq a1,string_java_lang_ArithmeticException_message
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_idiv
*******************************************************************************/
.ent asm_builtin_ldiv
-asm_builtin_ldiv:
+asm_builtin_ldiv:
ldgp gp,0(pv)
lda pv,builtin_ldiv
beq a1,nb_ldiv /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_ldiv */
nb_ldiv:
- ldq xptr,proto_java_lang_ArithmeticException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_ArithmeticException
+ ldq a1,string_java_lang_ArithmeticException_message
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_ldiv
*******************************************************************************/
.ent asm_builtin_irem
-asm_builtin_irem:
+asm_builtin_irem:
ldgp gp,0(pv)
lda pv,builtin_irem
beq a1,nb_irem /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_irem */
nb_irem:
- ldq xptr,proto_java_lang_ArithmeticException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_ArithmeticException
+ ldq a1,string_java_lang_ArithmeticException_message
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_irem
*******************************************************************************/
.ent asm_builtin_lrem
-asm_builtin_lrem:
+asm_builtin_lrem:
ldgp gp,0(pv)
lda pv,builtin_lrem
beq a1,nb_lrem /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_lrem */
nb_lrem:
- ldq xptr,proto_java_lang_ArithmeticException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_ArithmeticException
+ ldq a1,string_java_lang_ArithmeticException_message
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_lrem
*******************************************************************************/
.ent asm_builtin_checkcast
-asm_builtin_checkcast:
+asm_builtin_checkcast:
ldgp gp,0(pv)
lda sp,-16(sp) # allocate stack space
stq ra,0(sp) # save return address
jmp zero,(ra)
nb_ccast_throw:
- ldq xptr,proto_java_lang_ClassCastException
+ ldq a0,string_java_lang_ClassCastException
+ jsr ra,new_exception
+ ldgp gp,0(ra)
+ mov v0,xptr
+
ldq ra,0(sp) # restore return address
lda sp,16(sp) # free stack space
lda xpc,-4(ra) # faulting address is return adress - 4
br asm_handle_nat_exception
+
.end asm_builtin_checkcast
*******************************************************************************/
.ent asm_builtin_checkarraycast
-asm_builtin_checkarraycast:
+asm_builtin_checkarraycast:
ldgp gp,0(pv)
lda sp,-16(sp) /* allocate stack space */
stq ra,0(sp) /* save return address */
jmp zero,(ra)
nb_carray_throw:
- ldq xptr,proto_java_lang_ClassCastException
+ ldq a0,string_java_lang_ClassCastException
+ jsr ra,new_exception
+ ldgp gp,0(ra)
+ mov v0,xptr
+
ldq ra,0(sp) /* restore return address */
lda sp,16(sp) /* free stack space */
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_checkarraycast
*******************************************************************************/
.ent asm_builtin_aastore
-asm_builtin_aastore:
+asm_builtin_aastore:
ldgp gp,0(pv)
beq a0,nb_aastore_null /* if null pointer throw exception */
ldl t0,offarraysize(a0) /* load size */
stq a1,offobjarrdata(a0) /* store objectptr in array */
jmp zero,(ra)
-nb_aastore_null:
- ldq xptr,proto_java_lang_NullPointerException
+nb_aastore_null:
+ subq sp,8,sp /* allocate stack space */
+ stq ra,0(sp) /* save return address */
+ ldq a0,string_java_lang_NullPointerException
+ jsr ra,new_exception
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
mov ra,xpc /* faulting address is return adress */
br asm_handle_nat_exception
nb_aastore_bound:
- ldq xptr,proto_java_lang_ArrayIndexOutOfBoundsException
+ ldq a0,string_java_lang_ArrayIndexOutOfBoundsException
+ jsr ra,new_exception_int /* a1 already contains the index */
+ ldgp gp,0(ra)
+ mov v0,xptr
+
+ ldq ra,0(sp) /* restore return address */
lda sp,24(sp) /* free stack space */
mov ra,xpc /* faulting address is return adress */
br asm_handle_nat_exception
nb_aastore_throw:
- ldq xptr,proto_java_lang_ArrayStoreException
+ subq sp,8,sp /* allocate stack space */
+ stq ra,0(sp) /* save return address */
+ ldq a0,string_java_lang_ArrayStoreException
+ jsr ra,new_exception
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
mov ra,xpc /* faulting address is return adress */
br asm_handle_nat_exception
*******************************************************************************/
.ent asm_initialize_thread_stack
-asm_initialize_thread_stack:
+asm_initialize_thread_stack:
lda a1,-128(a1)
stq zero, 0(a1)
stq zero, 8(a1)
stq a0, 120(a1)
mov a1, v0
jmp zero,(ra)
+
.end asm_initialize_thread_stack
*******************************************************************************/
.ent asm_perform_threadswitch
-asm_perform_threadswitch:
+asm_perform_threadswitch:
subq sp,128,sp
stq s0, 0(sp)
stq s1, 8(sp)
mov ra, pv
addq sp, 128, sp
jmp zero,(ra)
+
.end asm_perform_threadswitch
.ent asm_switchstackandcall
+
asm_switchstackandcall:
lda a0,-2*8(a0) /* allocate new stack */
stq ra,0(a0) /* save return address on new stack */
.ent asm_getcallingmethod
-asm_getcallingmethod:
+asm_getcallingmethod:
ldq t3,16(sp) /* load return address of native function */
addq sp,24,t2 /* skip frames of C-Function and nativestub */
pv_ok2:
ldq v0,MethodPointer(t4) /* */
-
- jmp zero,(ra) /* return */
+ jmp zero,(ra) /* return */
.end asm_getcallingmethod
Authors: Andreas Krall
Reinhard Grafl
- $Id: codegen.c 901 2004-01-22 19:06:00Z twisti $
+ $Id: codegen.c 948 2004-03-07 22:12:28Z twisti $
*/
/* gen_nullptr_check(objreg) */
-#ifdef SOFTNULLPTRCHECK
#define gen_nullptr_check(objreg) \
- if (checknull) {\
- M_BEQZ((objreg), 0);\
- codegen_addxnullrefs(mcodeptr);\
- }
-#else
-#define gen_nullptr_check(objreg)
-#endif
+ if (checknull) { \
+ M_BEQZ((objreg), 0); \
+ codegen_addxnullrefs(mcodeptr); \
+ }
/* MCODECHECK(icnt) */
if a and b are the same int-register, no code will be generated.
*/
-#define M_INTMOVE(a,b) if(a!=b){M_MOV(a,b);}
+#define M_INTMOVE(a,b) if (a != b) { M_MOV(a, b); }
/* M_FLTMOVE:
if a and b are the same float-register, no code will be generated
*/
-#define M_FLTMOVE(a,b) if(a!=b){M_FMOV(a,b);}
+#define M_FLTMOVE(a,b) if (a != b) { M_FMOV(a, b); }
/* var_to_reg_xxx:
sigemptyset(&nsig);
sigaddset(&nsig, sig);
sigprocmask(SIG_UNBLOCK, &nsig, NULL); /* unblock signal */
+
+ if (!proto_java_lang_NullPointerException) {
+ proto_java_lang_NullPointerException =
+ new_exception(string_java_lang_NullPointerException);
+ }
+
sigctx->sc_regs[REG_ITMP1_XPTR] =
(long) proto_java_lang_NullPointerException;
sigctx->sc_regs[REG_ITMP2_XPC] = sigctx->sc_pc;
sigctx->sc_pc = (long) asm_handle_exception;
return;
- }
- else {
+
+ } else {
faultaddr += (long) ((instr << 16) >> 16);
fprintf(stderr, "faulting address: 0x%16lx\n", faultaddr);
panic("Stack overflow");
- }
+ }
}
/* install signal handlers we need to convert to exceptions */
if (!checknull) {
-
#if defined(SIGSEGV)
signal(SIGSEGV, (void*) catch_NullPointerException);
#endif
#if defined(SIGBUS)
signal(SIGBUS, (void*) catch_NullPointerException);
#endif
- }
+ }
}
*******************************************************************************/
-#define MethodPointer -8
-#define FrameSize -12
-#define IsSync -16
-#define IsLeaf -20
-#define IntSave -24
-#define FltSave -28
-#define ExTableSize -32
-#define ExTableStart -32
-
-#define ExEntrySize -32
-#define ExStartPC -8
-#define ExEndPC -16
-#define ExHandlerPC -24
-#define ExCatchType -32
-
void codegen()
{
int len, s1, s2, s3, d;
*/
#define gen_bound_check \
- if (checkbounds) { \
- M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
- M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
- M_BEQZ(REG_ITMP3, 0);\
- codegen_addxboundrefs(mcodeptr); \
- }
+ if (checkbounds) { \
+ M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
+ M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
+ M_BEQZ(REG_ITMP3, 0);\
+ codegen_addxboundrefs(mcodeptr, s2); \
+ }
case ICMD_ARRAYLENGTH: /* ..., arrayref ==> ..., length */
for (; xboundrefs != NULL; xboundrefs = xboundrefs->next) {
if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xboundrefs->branchpos,
- xboundrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
+ xboundrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - (4 + 4));
continue;
- }
+ }
gen_resolvebranch((u1*) mcodebase + xboundrefs->branchpos,
MCODECHECK(8);
+ M_MOV(xboundrefs->reg, REG_ITMP1);
M_LDA(REG_ITMP2_XPC, REG_PV, xboundrefs->branchpos - 4);
if (xcodeptr != NULL) {
- int disp = (xcodeptr-mcodeptr)-1;
- M_BR(disp);
- }
- else {
+ M_BR(xcodeptr - mcodeptr - 1);
+
+ } else {
xcodeptr = mcodeptr;
- a = dseg_addaddress(proto_java_lang_ArrayIndexOutOfBoundsException);
- M_ALD(REG_ITMP1_XPTR, REG_PV, a);
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+
+ a = dseg_addaddress(string_java_lang_ArrayIndexOutOfBoundsException);
+ M_ALD(argintregs[0], REG_PV, a);
+ M_MOV(REG_ITMP1, argintregs[1]);
+
+ a = dseg_addaddress(new_exception_int);
+ M_ALD(REG_PV, REG_PV, a);
+ M_JSR(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
+
+ M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+
+ M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+ M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
a = dseg_addaddress(asm_handle_exception);
M_ALD(REG_ITMP3, REG_PV, a);
M_JMP(REG_ZERO, REG_ITMP3);
- }
}
+ }
/* generate negative array size check stubs */
gen_resolvebranch((u1*) mcodebase + xcheckarefs->branchpos,
xcheckarefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
continue;
- }
+ }
gen_resolvebranch((u1*) mcodebase + xcheckarefs->branchpos,
xcheckarefs->branchpos, (u1*) mcodeptr - mcodebase);
M_LDA(REG_ITMP2_XPC, REG_PV, xcheckarefs->branchpos - 4);
if (xcodeptr != NULL) {
- int disp = (xcodeptr-mcodeptr)-1;
- M_BR(disp);
- }
- else {
+ M_BR(xcodeptr - mcodeptr - 1);
+
+ } else {
xcodeptr = mcodeptr;
- a = dseg_addaddress(proto_java_lang_NegativeArraySizeException);
- M_ALD(REG_ITMP1_XPTR, REG_PV, a);
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+
+ a = dseg_addaddress(string_java_lang_NegativeArraySizeException);
+ M_ALD(argintregs[0], REG_PV, a);
+
+ a = dseg_addaddress(new_exception);
+ M_ALD(REG_PV, REG_PV, a);
+ M_JSR(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
+
+ M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+
+ M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+ M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
a = dseg_addaddress(asm_handle_exception);
M_ALD(REG_ITMP3, REG_PV, a);
M_JMP(REG_ZERO, REG_ITMP3);
- }
}
+ }
/* generate cast check stubs */
gen_resolvebranch((u1*) mcodebase + xcastrefs->branchpos,
xcastrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
continue;
- }
+ }
gen_resolvebranch((u1*) mcodebase + xcastrefs->branchpos,
xcastrefs->branchpos, (u1*) mcodeptr - mcodebase);
M_LDA(REG_ITMP2_XPC, REG_PV, xcastrefs->branchpos - 4);
if (xcodeptr != NULL) {
- int disp = (xcodeptr-mcodeptr)-1;
- M_BR(disp);
- }
- else {
+ M_BR(xcodeptr - mcodeptr - 1);
+
+ } else {
xcodeptr = mcodeptr;
- a = dseg_addaddress(proto_java_lang_ClassCastException);
- M_ALD(REG_ITMP1_XPTR, REG_PV, a);
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+
+ a = dseg_addaddress(string_java_lang_ClassCastException);
+ M_ALD(argintregs[0], REG_PV, a);
+
+ a = dseg_addaddress(new_exception);
+ M_ALD(REG_PV, REG_PV, a);
+ M_JSR(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
+
+ M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+
+ M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+ M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
a = dseg_addaddress(asm_handle_exception);
M_ALD(REG_ITMP3, REG_PV, a);
M_JMP(REG_ZERO, REG_ITMP3);
- }
}
-
-
-#ifdef SOFTNULLPTRCHECK
+ }
/* generate null pointer check stubs */
gen_resolvebranch((u1*) mcodebase + xnullrefs->branchpos,
xnullrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
continue;
- }
+ }
gen_resolvebranch((u1*) mcodebase + xnullrefs->branchpos,
xnullrefs->branchpos, (u1*) mcodeptr - mcodebase);
M_LDA(REG_ITMP2_XPC, REG_PV, xnullrefs->branchpos - 4);
if (xcodeptr != NULL) {
- int disp = (xcodeptr-mcodeptr)-1;
- M_BR(disp);
- }
- else {
+ M_BR(xcodeptr - mcodeptr - 1);
+
+ } else {
xcodeptr = mcodeptr;
- a = dseg_addaddress(proto_java_lang_NullPointerException);
- M_ALD(REG_ITMP1_XPTR, REG_PV, a);
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+
+ a = dseg_addaddress(string_java_lang_NullPointerException);
+ M_ALD(argintregs[0], REG_PV, a);
+
+ a = dseg_addaddress(new_exception);
+ M_ALD(REG_PV, REG_PV, a);
+ M_JSR(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
+
+ M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+
+ M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+ M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
a = dseg_addaddress(asm_handle_exception);
M_ALD(REG_ITMP3, REG_PV, a);
M_JMP(REG_ZERO, REG_ITMP3);
- }
}
-
-#endif
+ }
}
codegen_finish((int)((u1*) mcodeptr - mcodebase));
Authors: Andreas Krall
Reinhard Grafl
- $Id: asmpart.S 901 2004-01-22 19:06:00Z twisti $
+ $Id: asmpart.S 948 2004-03-07 22:12:28Z twisti $
*/
/********************* function synchronize_caches ****************************/
.ent synchronize_caches
-synchronize_caches:
+synchronize_caches:
call_pal PAL_imb /* synchronise instruction cache */
jmp zero,(ra) /* return */
.ent asm_builtin_monitorenter
asm_builtin_monitorenter:
-
ldgp gp,0(pv)
lda pv,builtin_monitorenter
beq a0,nb_monitorenter /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_monitorenter */
nb_monitorenter:
- ldq xptr,proto_java_lang_NullPointerException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_NullPointerException
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
.end asm_builtin_monitorenter
.ent asm_builtin_monitorexit
asm_builtin_monitorexit:
-
ldgp gp,0(pv)
lda pv,builtin_monitorexit
beq a0,nb_monitorexit /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_monitorexit */
nb_monitorexit:
- ldq xptr,proto_java_lang_NullPointerException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_NullPointerException
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
.end asm_builtin_monitorexit
*******************************************************************************/
.ent asm_builtin_idiv
-asm_builtin_idiv:
+asm_builtin_idiv:
ldgp gp,0(pv)
lda pv,builtin_idiv
beq a1,nb_idiv /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_idiv */
nb_idiv:
- ldq xptr,proto_java_lang_ArithmeticException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_ArithmeticException
+ ldq a1,string_java_lang_ArithmeticException_message
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_idiv
*******************************************************************************/
.ent asm_builtin_ldiv
-asm_builtin_ldiv:
+asm_builtin_ldiv:
ldgp gp,0(pv)
lda pv,builtin_ldiv
beq a1,nb_ldiv /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_ldiv */
nb_ldiv:
- ldq xptr,proto_java_lang_ArithmeticException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_ArithmeticException
+ ldq a1,string_java_lang_ArithmeticException_message
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_ldiv
*******************************************************************************/
.ent asm_builtin_irem
-asm_builtin_irem:
+asm_builtin_irem:
ldgp gp,0(pv)
lda pv,builtin_irem
beq a1,nb_irem /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_irem */
nb_irem:
- ldq xptr,proto_java_lang_ArithmeticException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_ArithmeticException
+ ldq a1,string_java_lang_ArithmeticException_message
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_irem
*******************************************************************************/
.ent asm_builtin_lrem
-asm_builtin_lrem:
+asm_builtin_lrem:
ldgp gp,0(pv)
lda pv,builtin_lrem
beq a1,nb_lrem /* if (null) throw exception */
jmp zero,(pv) /* else call builtin_lrem */
nb_lrem:
- ldq xptr,proto_java_lang_ArithmeticException
+ subq sp,8,sp
+ stq ra,0(sp)
+ ldq a0,string_java_lang_ArithmeticException
+ ldq a1,string_java_lang_ArithmeticException_message
+ jsr ra,new_exception_message
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_lrem
*******************************************************************************/
.ent asm_builtin_checkcast
-asm_builtin_checkcast:
+asm_builtin_checkcast:
ldgp gp,0(pv)
lda sp,-16(sp) # allocate stack space
stq ra,0(sp) # save return address
jmp zero,(ra)
nb_ccast_throw:
- ldq xptr,proto_java_lang_ClassCastException
+ ldq a0,string_java_lang_ClassCastException
+ jsr ra,new_exception
+ ldgp gp,0(ra)
+ mov v0,xptr
+
ldq ra,0(sp) # restore return address
lda sp,16(sp) # free stack space
lda xpc,-4(ra) # faulting address is return adress - 4
br asm_handle_nat_exception
+
.end asm_builtin_checkcast
*******************************************************************************/
.ent asm_builtin_checkarraycast
-asm_builtin_checkarraycast:
+asm_builtin_checkarraycast:
ldgp gp,0(pv)
lda sp,-16(sp) /* allocate stack space */
stq ra,0(sp) /* save return address */
jmp zero,(ra)
nb_carray_throw:
- ldq xptr,proto_java_lang_ClassCastException
+ ldq a0,string_java_lang_ClassCastException
+ jsr ra,new_exception
+ ldgp gp,0(ra)
+ mov v0,xptr
+
ldq ra,0(sp) /* restore return address */
lda sp,16(sp) /* free stack space */
lda xpc,-4(ra) /* faulting address is return adress - 4*/
br asm_handle_nat_exception
+
.end asm_builtin_checkarraycast
*******************************************************************************/
.ent asm_builtin_aastore
-asm_builtin_aastore:
+asm_builtin_aastore:
ldgp gp,0(pv)
beq a0,nb_aastore_null /* if null pointer throw exception */
ldl t0,offarraysize(a0) /* load size */
stq a1,offobjarrdata(a0) /* store objectptr in array */
jmp zero,(ra)
-nb_aastore_null:
- ldq xptr,proto_java_lang_NullPointerException
+nb_aastore_null:
+ subq sp,8,sp /* allocate stack space */
+ stq ra,0(sp) /* save return address */
+ ldq a0,string_java_lang_NullPointerException
+ jsr ra,new_exception
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
mov ra,xpc /* faulting address is return adress */
br asm_handle_nat_exception
nb_aastore_bound:
- ldq xptr,proto_java_lang_ArrayIndexOutOfBoundsException
+ ldq a0,string_java_lang_ArrayIndexOutOfBoundsException
+ jsr ra,new_exception_int /* a1 already contains the index */
+ ldgp gp,0(ra)
+ mov v0,xptr
+
+ ldq ra,0(sp) /* restore return address */
lda sp,24(sp) /* free stack space */
mov ra,xpc /* faulting address is return adress */
br asm_handle_nat_exception
nb_aastore_throw:
- ldq xptr,proto_java_lang_ArrayStoreException
+ subq sp,8,sp /* allocate stack space */
+ stq ra,0(sp) /* save return address */
+ ldq a0,string_java_lang_ArrayStoreException
+ jsr ra,new_exception
+ ldgp gp,0(ra)
+ mov v0,xptr
+ ldq ra,0(sp)
+ addq sp,8,sp
+
mov ra,xpc /* faulting address is return adress */
br asm_handle_nat_exception
*******************************************************************************/
.ent asm_initialize_thread_stack
-asm_initialize_thread_stack:
+asm_initialize_thread_stack:
lda a1,-128(a1)
stq zero, 0(a1)
stq zero, 8(a1)
stq a0, 120(a1)
mov a1, v0
jmp zero,(ra)
+
.end asm_initialize_thread_stack
*******************************************************************************/
.ent asm_perform_threadswitch
-asm_perform_threadswitch:
+asm_perform_threadswitch:
subq sp,128,sp
stq s0, 0(sp)
stq s1, 8(sp)
mov ra, pv
addq sp, 128, sp
jmp zero,(ra)
+
.end asm_perform_threadswitch
.ent asm_switchstackandcall
+
asm_switchstackandcall:
lda a0,-2*8(a0) /* allocate new stack */
stq ra,0(a0) /* save return address on new stack */
.ent asm_getcallingmethod
-asm_getcallingmethod:
+asm_getcallingmethod:
ldq t3,16(sp) /* load return address of native function */
addq sp,24,t2 /* skip frames of C-Function and nativestub */
pv_ok2:
ldq v0,MethodPointer(t4) /* */
-
- jmp zero,(ra) /* return */
+ jmp zero,(ra) /* return */
.end asm_getcallingmethod
Authors: Andreas Krall
Reinhard Grafl
- $Id: codegen.c 901 2004-01-22 19:06:00Z twisti $
+ $Id: codegen.c 948 2004-03-07 22:12:28Z twisti $
*/
/* gen_nullptr_check(objreg) */
-#ifdef SOFTNULLPTRCHECK
#define gen_nullptr_check(objreg) \
- if (checknull) {\
- M_BEQZ((objreg), 0);\
- codegen_addxnullrefs(mcodeptr);\
- }
-#else
-#define gen_nullptr_check(objreg)
-#endif
+ if (checknull) { \
+ M_BEQZ((objreg), 0); \
+ codegen_addxnullrefs(mcodeptr); \
+ }
/* MCODECHECK(icnt) */
if a and b are the same int-register, no code will be generated.
*/
-#define M_INTMOVE(a,b) if(a!=b){M_MOV(a,b);}
+#define M_INTMOVE(a,b) if (a != b) { M_MOV(a, b); }
/* M_FLTMOVE:
if a and b are the same float-register, no code will be generated
*/
-#define M_FLTMOVE(a,b) if(a!=b){M_FMOV(a,b);}
+#define M_FLTMOVE(a,b) if (a != b) { M_FMOV(a, b); }
/* var_to_reg_xxx:
sigemptyset(&nsig);
sigaddset(&nsig, sig);
sigprocmask(SIG_UNBLOCK, &nsig, NULL); /* unblock signal */
+
+ if (!proto_java_lang_NullPointerException) {
+ proto_java_lang_NullPointerException =
+ new_exception(string_java_lang_NullPointerException);
+ }
+
sigctx->sc_regs[REG_ITMP1_XPTR] =
(long) proto_java_lang_NullPointerException;
sigctx->sc_regs[REG_ITMP2_XPC] = sigctx->sc_pc;
sigctx->sc_pc = (long) asm_handle_exception;
return;
- }
- else {
+
+ } else {
faultaddr += (long) ((instr << 16) >> 16);
fprintf(stderr, "faulting address: 0x%16lx\n", faultaddr);
panic("Stack overflow");
- }
+ }
}
/* install signal handlers we need to convert to exceptions */
if (!checknull) {
-
#if defined(SIGSEGV)
signal(SIGSEGV, (void*) catch_NullPointerException);
#endif
#if defined(SIGBUS)
signal(SIGBUS, (void*) catch_NullPointerException);
#endif
- }
+ }
}
*******************************************************************************/
-#define MethodPointer -8
-#define FrameSize -12
-#define IsSync -16
-#define IsLeaf -20
-#define IntSave -24
-#define FltSave -28
-#define ExTableSize -32
-#define ExTableStart -32
-
-#define ExEntrySize -32
-#define ExStartPC -8
-#define ExEndPC -16
-#define ExHandlerPC -24
-#define ExCatchType -32
-
void codegen()
{
int len, s1, s2, s3, d;
*/
#define gen_bound_check \
- if (checkbounds) { \
- M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
- M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
- M_BEQZ(REG_ITMP3, 0);\
- codegen_addxboundrefs(mcodeptr); \
- }
+ if (checkbounds) { \
+ M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
+ M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
+ M_BEQZ(REG_ITMP3, 0);\
+ codegen_addxboundrefs(mcodeptr, s2); \
+ }
case ICMD_ARRAYLENGTH: /* ..., arrayref ==> ..., length */
for (; xboundrefs != NULL; xboundrefs = xboundrefs->next) {
if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xboundrefs->branchpos,
- xboundrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
+ xboundrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - (4 + 4));
continue;
- }
+ }
gen_resolvebranch((u1*) mcodebase + xboundrefs->branchpos,
MCODECHECK(8);
+ M_MOV(xboundrefs->reg, REG_ITMP1);
M_LDA(REG_ITMP2_XPC, REG_PV, xboundrefs->branchpos - 4);
if (xcodeptr != NULL) {
- int disp = (xcodeptr-mcodeptr)-1;
- M_BR(disp);
- }
- else {
+ M_BR(xcodeptr - mcodeptr - 1);
+
+ } else {
xcodeptr = mcodeptr;
- a = dseg_addaddress(proto_java_lang_ArrayIndexOutOfBoundsException);
- M_ALD(REG_ITMP1_XPTR, REG_PV, a);
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+
+ a = dseg_addaddress(string_java_lang_ArrayIndexOutOfBoundsException);
+ M_ALD(argintregs[0], REG_PV, a);
+ M_MOV(REG_ITMP1, argintregs[1]);
+
+ a = dseg_addaddress(new_exception_int);
+ M_ALD(REG_PV, REG_PV, a);
+ M_JSR(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
+
+ M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+
+ M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+ M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
a = dseg_addaddress(asm_handle_exception);
M_ALD(REG_ITMP3, REG_PV, a);
M_JMP(REG_ZERO, REG_ITMP3);
- }
}
+ }
/* generate negative array size check stubs */
gen_resolvebranch((u1*) mcodebase + xcheckarefs->branchpos,
xcheckarefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
continue;
- }
+ }
gen_resolvebranch((u1*) mcodebase + xcheckarefs->branchpos,
xcheckarefs->branchpos, (u1*) mcodeptr - mcodebase);
M_LDA(REG_ITMP2_XPC, REG_PV, xcheckarefs->branchpos - 4);
if (xcodeptr != NULL) {
- int disp = (xcodeptr-mcodeptr)-1;
- M_BR(disp);
- }
- else {
+ M_BR(xcodeptr - mcodeptr - 1);
+
+ } else {
xcodeptr = mcodeptr;
- a = dseg_addaddress(proto_java_lang_NegativeArraySizeException);
- M_ALD(REG_ITMP1_XPTR, REG_PV, a);
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+
+ a = dseg_addaddress(string_java_lang_NegativeArraySizeException);
+ M_ALD(argintregs[0], REG_PV, a);
+
+ a = dseg_addaddress(new_exception);
+ M_ALD(REG_PV, REG_PV, a);
+ M_JSR(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
+
+ M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+
+ M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+ M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
a = dseg_addaddress(asm_handle_exception);
M_ALD(REG_ITMP3, REG_PV, a);
M_JMP(REG_ZERO, REG_ITMP3);
- }
}
+ }
/* generate cast check stubs */
gen_resolvebranch((u1*) mcodebase + xcastrefs->branchpos,
xcastrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
continue;
- }
+ }
gen_resolvebranch((u1*) mcodebase + xcastrefs->branchpos,
xcastrefs->branchpos, (u1*) mcodeptr - mcodebase);
M_LDA(REG_ITMP2_XPC, REG_PV, xcastrefs->branchpos - 4);
if (xcodeptr != NULL) {
- int disp = (xcodeptr-mcodeptr)-1;
- M_BR(disp);
- }
- else {
+ M_BR(xcodeptr - mcodeptr - 1);
+
+ } else {
xcodeptr = mcodeptr;
- a = dseg_addaddress(proto_java_lang_ClassCastException);
- M_ALD(REG_ITMP1_XPTR, REG_PV, a);
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+
+ a = dseg_addaddress(string_java_lang_ClassCastException);
+ M_ALD(argintregs[0], REG_PV, a);
+
+ a = dseg_addaddress(new_exception);
+ M_ALD(REG_PV, REG_PV, a);
+ M_JSR(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
+
+ M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+
+ M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+ M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
a = dseg_addaddress(asm_handle_exception);
M_ALD(REG_ITMP3, REG_PV, a);
M_JMP(REG_ZERO, REG_ITMP3);
- }
}
-
-
-#ifdef SOFTNULLPTRCHECK
+ }
/* generate null pointer check stubs */
gen_resolvebranch((u1*) mcodebase + xnullrefs->branchpos,
xnullrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
continue;
- }
+ }
gen_resolvebranch((u1*) mcodebase + xnullrefs->branchpos,
xnullrefs->branchpos, (u1*) mcodeptr - mcodebase);
M_LDA(REG_ITMP2_XPC, REG_PV, xnullrefs->branchpos - 4);
if (xcodeptr != NULL) {
- int disp = (xcodeptr-mcodeptr)-1;
- M_BR(disp);
- }
- else {
+ M_BR(xcodeptr - mcodeptr - 1);
+
+ } else {
xcodeptr = mcodeptr;
- a = dseg_addaddress(proto_java_lang_NullPointerException);
- M_ALD(REG_ITMP1_XPTR, REG_PV, a);
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+
+ a = dseg_addaddress(string_java_lang_NullPointerException);
+ M_ALD(argintregs[0], REG_PV, a);
+
+ a = dseg_addaddress(new_exception);
+ M_ALD(REG_PV, REG_PV, a);
+ M_JSR(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
+
+ M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+
+ M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+ M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
a = dseg_addaddress(asm_handle_exception);
M_ALD(REG_ITMP3, REG_PV, a);
M_JMP(REG_ZERO, REG_ITMP3);
- }
}
-
-#endif
+ }
}
codegen_finish((int)((u1*) mcodeptr - mcodebase));