Changes: Christian Thalinger
- $Id: VMThrowable.c 2358 2005-04-22 22:01:51Z jowenn $
+ $Id: VMThrowable.c 2360 2005-04-24 13:07:57Z jowenn $
*/
#include "vm/tables.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/stacktrace.h"
+#include "vm/exceptions.h"
/*
{
java_lang_VMThrowable *vmthrow;
+ if ((*dontfillinexceptionstacktrace) == true) {
+ /*log_text("dontfillinexceptionstacktrace");*/
+ return 0;
+ }
+
vmthrow = (java_lang_VMThrowable *) native_new_and_init(class_java_lang_VMThrowable);
if (!vmthrow)
Authors: Stefan Ring
- $Id: threads.h 1923 2005-02-10 10:43:41Z twisti $
+ $Id: threads.h 2360 2005-04-24 13:07:57Z jowenn $
*/
threadobject *next;
threadobject *prev;
java_objectheader *_exceptionptr;
+ u1 _dontfillinexceptionstacktrace;
methodinfo *_threadrootmethod;
void *_stackframeinfo;
pthread_t tid;
Changes: Edwin Steiner
Christian Thalinger
- $Id: builtin.h 2357 2005-04-22 17:37:57Z christian $
+ $Id: builtin.h 2360 2005-04-24 13:07:57Z jowenn $
*/
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
static inline java_objectheader **builtin_get_exceptionptrptr(void);
+static inline u1 *builtin_get_dontfillinexceptionstacktrace(void);
/* NOT AN OP */
static inline methodinfo **builtin_get_threadrootmethod(void);
/* NOT AN OP */
return &THREADINFO->_exceptionptr;
}
+inline u1 *builtin_get_dontfillinexceptionstacktrace(void)
+{
+ return &THREADINFO->_dontfillinexceptionstacktrace;
+}
+
inline methodinfo **builtin_get_threadrootmethod(void)
{
return &THREADINFO->_threadrootmethod;
Changes:
- $Id: exceptions.c 2276 2005-04-12 19:47:33Z twisti $
+ $Id: exceptions.c 2360 2005-04-24 13:07:57Z jowenn $
*/
#if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
java_objectheader* _exceptionptr = NULL;
+u1 _dontfillinexceptionstacktrace = false;
#endif
Changes:
- $Id: exceptions.h 2276 2005-04-12 19:47:33Z twisti $
+ $Id: exceptions.h 2360 2005-04-24 13:07:57Z jowenn $
*/
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
-#define exceptionptr builtin_get_exceptionptrptr()
-#define threadrootmethod builtin_get_threadrootmethod()
+#define exceptionptr builtin_get_exceptionptrptr()
+#define dontfillinexceptionstacktrace builtin_get_dontfillinexceptionstacktrace()
+#define threadrootmethod builtin_get_threadrootmethod()
#else /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
#define exceptionptr (&_exceptionptr)
+#define dontfillinexceptionstacktrace (&_dontfillinexceptionstacktrace)
#define threadrootmethod (&_threadrootmethod)
#endif /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
#if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
extern java_objectheader *_exceptionptr;
+extern u1 _dontfillinexceptionstacktrace;
extern methodinfo* _threadrootmethod;
#endif /* !defined(USE_THREADS) || !defined(NATIVE_THREADS) */
Changes:
- $Id: helper.c 2332 2005-04-22 13:21:02Z twisti $
+ $Id: helper.c 2360 2005-04-24 13:07:57Z jowenn $
*/
#include "vm/method.h"
#include "vm/references.h"
#include "vm/resolve.h"
+#include "vm/linker.h"
/* XXX class_resolveclassmethod */
#include "vm/loader.h"
}
+/* helper_fillin_stacktrace ****************************************************
+
+ This function returns the exception given as parameter with a filled in stacktrace
+
+*******************************************************************************/
+
+java_objectheader *helper_fillin_stacktrace(java_objectheader* exc)
+{
+ classinfo *c;
+ methodinfo *m;
+ /*log_text("helper_fillin_stacktrace has beenentered");*/
+ /* these are panics, since this are sever problems, which must never happen*/
+ if (exc==0) panic("Exception must not be null in helper_fillin_stacktrace");
+ if ( ((java_lang_Throwable *) exc)->vmState!=0) return exc;
+ if (exc->vftbl==0) panic ("Exception vftbl must not be null in helper_fillin_stacktrace");
+ /*get classinfo from object instance*/
+ c=exc->vftbl->class;
+ if (c==0) panic("Exception class must not be null in helper_fillin_stacktrace");
+ /*find the fillInStackTrace method*/
+ m=class_resolvemethod(c,utf_fillInStackTrace,utf_void__java_lang_Throwable);
+ if (m==0) panic ("Exception does not have a fillInStackTrace method");
+
+ /*log_text("helper_fillin_stacktrace doing it's work now");*/
+ asm_calljavafunction(m,exc,0,0,0);
+
+ /*return exception back to asmpart*/
+ return exc;
+}
+
+java_objectheader *helper_fillin_stacktrace_always(java_objectheader* exc) {
+ if (exc==0) panic("Exception must not be null in helper_fillin_stacktrace");
+ ((java_lang_Throwable *) exc)->vmState=0;
+ return helper_fillin_stacktrace(exc);
+}
+
+
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
Changes:
- $Id: helper.h 2355 2005-04-22 14:57:47Z twisti $
+ $Id: helper.h 2360 2005-04-24 13:07:57Z jowenn $
*/
classinfo *helper_resolve_classinfo(constant_classref *cr);
methodinfo *helper_resolve_methodinfo(unresolved_method *um);
fieldinfo *helper_resolve_fieldinfo(unresolved_field *uf);
+java_objectheader *helper_fillin_stacktrace(java_objectheader*);
+java_objectheader *helper_fillin_stacktrace_always(java_objectheader*);
#endif /* _HELPER_H */
Changes:
- $Id: stacktrace.h 2123 2005-03-29 22:12:32Z twisti $
+ $Id: stacktrace.h 2360 2005-04-24 13:07:57Z jowenn $
*/
#ifdef __ALPHA__
void *savedpv;
#endif
- void *beginOfJavaStackframe; /*only used if != 0*/
+ void *beginOfJavaStackframe; /*only used if != 0*/ /* on i386 and x86_64 this points to the return addres stored directly below the stackframe*/
void *returnToFromNative;
#if 0
Reinhard Grafl
Christian Thalinger
- $Id: asmpart.S 2358 2005-04-22 22:01:51Z jowenn $
+ $Id: asmpart.S 2360 2005-04-24 13:07:57Z jowenn $
*/
ret /* call new patched code */
L_asm_wrapper_patcher_exception:
+ /*stack bottom is xpc and it is directly below the last java stackframe*/
+ push $0
+ push $0
+ push $0 /*padding*/
+ call asm_prepare_native_stackinfo /* be aware of the stack effect and calling convention explained above*/
+
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
call builtin_asm_get_exceptionptrptr
mov v0,itmp2
#else
lea _exceptionptr,itmp2
#endif
- mov (itmp2),xptr /* get the exception pointer */
- movl $0,(itmp2) /* clear the exception pointer */
+ mov (itmp2),a0 /* get the exception pointer */
+ movl $0,(itmp2) /* clear exception pointer */
+ call helper_fillin_stacktrace
+
+ mov v0,xptr
+
+ call asm_remove_native_stackinfo /* be aware of the stack effect and calling convention explained above*/
+ pop xpc
pop xpc /* get and remove return address */
jmp asm_handle_exception
jmp asm_throw_and_handle_exception
nb_aastore_bound:
- mov %rsi,%rdi /* move index into a0 */
+ add $24,%rsp
+ push $0 /*directly below return address*/
+ push $0 /*internal*/
+ push $0 /*padding*/
+ mov %rsi,itmp1
+
+ call asm_prepare_native_stackinfo
+
+ mov itmp1,%rdi /* move index into a0 */
call new_arrayindexoutofboundsexception
- add $24,%rsp
- pop %r10 /* delete return address */
- sub $3,%r10 /* faulting address is return adress - 3 */
+
+ call asm_remove_native_stackinfo
+
+ pop xpc /* just remove one quadword */
+ pop xpc /* delete return address */
+ sub $3,xpc /* faulting address is return adress - 3 */
jmp asm_handle_exception
nb_aastore_throw:
Authors: Andreas Krall
Christian Thalinger
- $Id: codegen.c 2358 2005-04-22 22:01:51Z jowenn $
+ $Id: codegen.c 2360 2005-04-24 13:07:57Z jowenn $
*/
#include "vm/jit/x86_64/emitfuncs.h"
#include "vm/jit/x86_64/types.h"
#include "vm/jit/x86_64/asmoffsets.h"
-
+#include "vm/jit/helper.h"
/* register descripton - array ************************************************/
#endif
-void dummy_func() { }
+void codegen_dummy_func() { log_text("codegen_dummy_func"); }
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
void thread_restartcriticalsection(ucontext_t *uc)
} else {
xcodeptr = cd->mcodeptr;
+
+
+ x86_64_alu_imm_reg(cd, X86_64_SUB, 4*8, REG_SP);
+ x86_64_mov_reg_membase(cd, REG_ITMP2_XPC, REG_SP, 3*8);
+ x86_64_mov_imm_membase(cd, 0, REG_SP, 2*8);
+ x86_64_mov_imm_membase(cd, 0, REG_SP, 1*8);
+ x86_64_mov_imm_membase(cd, 0, REG_SP, 0*8);
+ x86_64_mov_imm_reg(cd,(u8) asm_prepare_native_stackinfo,REG_ITMP1);
+ x86_64_call_reg(cd,REG_ITMP1);
+
+
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
- x86_64_alu_imm_reg(cd, X86_64_SUB, 8, REG_SP);
- x86_64_mov_reg_membase(cd, REG_ITMP2_XPC, REG_SP, 0);
x86_64_mov_imm_reg(cd, (u8) &builtin_get_exceptionptrptr, REG_ITMP1);
x86_64_call_reg(cd, REG_ITMP1);
x86_64_mov_membase_reg(cd, REG_RESULT, 0, REG_ITMP3);
x86_64_mov_imm_membase(cd, 0, REG_RESULT, 0);
x86_64_mov_reg_reg(cd, REG_ITMP3, REG_ITMP1_XPTR);
- x86_64_mov_membase_reg(cd, REG_SP, 0, REG_ITMP2_XPC);
- x86_64_alu_imm_reg(cd, X86_64_ADD, 8, REG_SP);
#else
x86_64_mov_imm_reg(cd, (u8) &_exceptionptr, REG_ITMP3);
x86_64_mov_membase_reg(cd, REG_ITMP3, 0, REG_ITMP1_XPTR);
x86_64_mov_imm_membase(cd, 0, REG_ITMP3, 0);
#endif
+ x86_64_mov_reg_reg(cd,REG_ITMP1_XPTR,RDI);
+ x86_64_mov_imm_reg(cd,(u8) helper_fillin_stacktrace_always,REG_ITMP1);
+ x86_64_call_reg(cd,REG_ITMP1);
+ x86_64_mov_reg_reg(cd,REG_RESULT,REG_ITMP1_XPTR);
+
+ x86_64_mov_imm_reg(cd,(u8) asm_remove_native_stackinfo,REG_ITMP2);
+ x86_64_call_reg(cd,REG_ITMP2);
+
+ x86_64_alu_imm_reg(cd, X86_64_ADD, 8, REG_SP);
+ x86_64_mov_membase_reg(cd, REG_SP, 0, REG_ITMP2_XPC);
+ x86_64_alu_imm_reg(cd, X86_64_ADD, 8, REG_SP);
+
x86_64_mov_imm_reg(cd, (u8) asm_handle_exception, REG_ITMP3);
x86_64_jmp_reg(cd, REG_ITMP3);
u1 *createnativestub(functionptr f, methodinfo *m)
{
- int gg;
u1 *s; /* pointer to stub memory */
codegendata *cd;
registerdata *rd;
Changes:
- $Id: patcher.c 2355 2005-04-22 14:57:47Z twisti $
+ $Id: patcher.c 2360 2005-04-24 13:07:57Z jowenn $
*/
#include "vm/initialize.h"
#include "vm/references.h"
#include "vm/jit/helper.h"
-
+#include "vm/exceptions.h"
/* patcher_get_putstatic *******************************************************
fieldinfo *fi;
ptrint *dataaddress;
s4 ripoffset;
-
+ void *beginJavaStack;
/* get stuff from the stack */
ra = (u1 *) *((ptrint *) (sp + 2 * 8));
mcode = *((u8 *) (sp + 1 * 8));
uf = (unresolved_field *) *((ptrint *) (sp + 0 * 8));
-
+ beginJavaStack= (void*)(sp+2*8);
/* calculate and set the new return address */
ra = ra - 5;
*((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
/* get the fieldinfo */
-
if (!(fi = helper_resolve_fieldinfo(uf)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* check if the field's class is initialized */
-
- if (!fi->class->initialized)
- if (!initialize_class(fi->class))
+ *dontfillinexceptionstacktrace=false;
+ if (!fi->class->initialized) {
+ bool init;
+ {
+ /*struct native_stackframeinfo {
+ void *oldThreadspecificHeadValue;
+ void **addressOfThreadspecificHead;
+ methodinfo *method;
+ void *beginOfJavaStackframe; only used if != 0
+ void *returnToFromNative;
+ }*/
+ /* more or less the same as the above sfi setup is done in the assembler code by the prepare/remove functions*/
+ native_stackframeinfo sfi;
+ sfi.returnToFromNative=(void*)ra;
+ sfi.beginOfJavaStackframe=beginJavaStack;
+ sfi.method=0; /*internal*/
+ sfi.addressOfThreadspecificHead=builtin_asm_get_stackframeinfo();
+ sfi.oldThreadspecificHeadValue=*(sfi.addressOfThreadspecificHead);
+ *(sfi.addressOfThreadspecificHead)=&sfi;
+
+ init=initialize_class(fi->class);
+
+ *(sfi.addressOfThreadspecificHead)=sfi.oldThreadspecificHeadValue;
+ }
+ if (!init)
+ {
return false;
+ }
+ }
+
+ *dontfillinexceptionstacktrace=false;
/* patch back original code */
ra = ra - 5;
*((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
+
/* get the fieldinfo */
if (!(fi = helper_resolve_fieldinfo(uf)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* patch back original code */
*((u4 *) (ra + 3)) = (u4) (fi->offset);
}
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - (10 + 10 + 3);
*((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
/* get the classinfo */
if (!(c = helper_resolve_classinfo(cr)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* patch the classinfo pointer */
*((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_new;
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - (10 + 10 + 3);
*((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
+
+ *dontfillinexceptionstacktrace=true;
+
+
/* get the classinfo */
if (!(c = helper_resolve_classinfo(cr)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
-
+ }
/* patch the class' vftbl pointer */
*((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
*((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_newarray;
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - (10 + 10 + 3 + 10 + 3);
*((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
/* get the classinfo */
- if (!(c = helper_resolve_classinfo(cr)))
+ if (!(c = helper_resolve_classinfo(cr))) {
+ *dontfillinexceptionstacktrace=false;
return false;
-
+ }
/* patch the class' vftbl pointer */
*((ptrint *) (ra + 10 + 2)) = (ptrint) c->vftbl;
*((ptrint *) (ra + 10 + 10 + 3 + 2)) = (ptrint) BUILTIN_multianewarray;
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - (10 + 10 + 3);
*((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
/* get the classinfo */
if (!(c = helper_resolve_classinfo(cr)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* patch the class' vftbl pointer */
*((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_checkarraycast;
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - (10 + 10 + 3);
*((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
+
+ *dontfillinexceptionstacktrace=true;
+
+
/* get the classinfo */
if (!(c = helper_resolve_classinfo(cr)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* patch the class' vftbl pointer */
*((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_arrayinstanceof;
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - 5;
*((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
+
/* get the fieldinfo */
if (!(m = helper_resolve_methodinfo(um)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
-
+ }
/* patch back original code */
*((u8 *) ra) = mcode;
*((ptrint *) (ra + 2)) = (ptrint) m->stubroutine;
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - 5;
*((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
/* get the fieldinfo */
if (!(m = helper_resolve_methodinfo(um)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* patch back original code */
*((s4 *) (ra + 3 + 3)) = (s4) (OFFSET(vftbl_t, table[0]) +
sizeof(methodptr) * m->vftblindex);
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - 5;
*((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
/* get the fieldinfo */
if (!(m = helper_resolve_methodinfo(um)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* patch back original code */
*((s4 *) (ra + 3 + 7 + 3)) =
(s4) (sizeof(methodptr) * (m - m->class->methods));
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - 5;
*((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
/* get the fieldinfo */
if (!(c = helper_resolve_classinfo(cr)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
-
+ }
/* patch back original code */
*((u8 *) ra) = mcode;
*((s4 *) (ra + 2)) = (s4) c->flags;
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - 5;
*((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
+
+ *dontfillinexceptionstacktrace=true;
+
/* get the fieldinfo */
if (!(c = helper_resolve_classinfo(cr)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* patch back original code */
(s4) (OFFSET(vftbl_t, interfacetable[0]) -
c->index * sizeof(methodptr*));
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - 5;
*((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
/* get the fieldinfo */
if (!(c = helper_resolve_classinfo(cr)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* patch back original code */
*((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
*((ptrint *) (ra + 10 + 7 + 7 + 3 + 2)) = (ptrint) c->vftbl;
+ *dontfillinexceptionstacktrace=false;
return true;
}
ra = ra - 5;
*((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
+ *dontfillinexceptionstacktrace=true;
+
/* get the fieldinfo */
if (!(c = helper_resolve_classinfo(cr)))
+ {
+ *dontfillinexceptionstacktrace=false;
return false;
+ }
/* patch back original code */
*((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
+ *dontfillinexceptionstacktrace=false;
return true;
}
u1 *ra;
u8 mcode;
classinfo *c;
+ void *beginJavaStack;
/* get stuff from the stack */
ra = (u1 *) *((ptrint *) (sp + 2 * 8));
mcode = *((u8 *) (sp + 1 * 8));
c = (classinfo *) *((ptrint *) (sp + 0 * 8));
+ beginJavaStack = (void*) (sp+2*8);
/* calculate and set the new return address */
/* check if the class is initialized */
if (!c->initialized)
- if (!initialize_class(c))
+ {
+ bool init;
+ {
+ /*struct native_stackframeinfo {
+ void *oldThreadspecificHeadValue;
+ void **addressOfThreadspecificHead;
+ methodinfo *method;
+ void *beginOfJavaStackframe; only used if != 0
+ void *returnToFromNative;
+ }*/
+ /* more or less the same as the above sfi setup is done in the assembler code by the prepare/remove functions*/
+ native_stackframeinfo sfi;
+ sfi.returnToFromNative=(void*)ra;
+ sfi.beginOfJavaStackframe=beginJavaStack;
+ sfi.method=0; /*internal*/
+ sfi.addressOfThreadspecificHead=builtin_asm_get_stackframeinfo();
+ sfi.oldThreadspecificHeadValue=*(sfi.addressOfThreadspecificHead);
+ *(sfi.addressOfThreadspecificHead)=&sfi;
+
+ init=initialize_class(c);
+
+ *(sfi.addressOfThreadspecificHead)=sfi.oldThreadspecificHeadValue;
+ }
+ if (!init)
+ {
return false;
+ }
+ }
/* patch back original code */