diff -aruN shujit-0.3.12/ChangeLog shujit/ChangeLog --- shujit-0.3.12/ChangeLog Tue Oct 12 16:40:48 1999 +++ shujit/ChangeLog Sat Oct 16 18:51:07 1999 @@ -1,5 +1,20 @@ $Id$ +[19991016] + +64bit 整数(long)型の 0除算で、__divdi3() 中で発生した SIGFPE を +きちんと扱えていなかったのを修整。 +(compiler.c, code.c) + +glibc 2.1 で、stdout のシンボル、取得方法が変わったことに対応。 +(code.h) + +スタック上で構造体 sigcontext を探す幅を広げた。50 word -> 100 word。 +glibc 2.1 では 70 を越えているため。 +(compiler.c) + +0.3.13 リリース。 + [19991006] 0.3.12 リリース。 diff -aruN shujit-0.3.12/GNUmakefile shujit/GNUmakefile --- shujit-0.3.12/GNUmakefile Tue Oct 12 16:38:34 1999 +++ shujit/GNUmakefile Sat Oct 16 19:16:38 1999 @@ -165,7 +165,7 @@ ${RM} -f metavm/Makefile NET/shudo/metavm/Makefile clean: subdirclean - ${RM} -f config.cache + ${RM} -f config.cache confdefs.h ${RM} -f TAGS *~ ${TARGET} *.o ${GENEDHDR} ${GENEDOBJ} ${GENEDOBJ:.o=.c} *.s ${TOOLS} ${TOOLSOBJ} java_*.h ifeq (${METAVM}, yes) ${RM} -f ${JARFILE} diff -aruN shujit-0.3.12/GNUmakefile.in shujit/GNUmakefile.in --- shujit-0.3.12/GNUmakefile.in Sun Aug 29 05:23:06 1999 +++ shujit/GNUmakefile.in Sat Oct 16 15:46:54 1999 @@ -165,7 +165,7 @@ ${RM} -f metavm/Makefile NET/shudo/metavm/Makefile clean: subdirclean - ${RM} -f config.cache + ${RM} -f config.cache confdefs.h ${RM} -f TAGS *~ ${TARGET} *.o ${GENEDHDR} ${GENEDOBJ} ${GENEDOBJ:.o=.c} *.s ${TOOLS} ${TOOLSOBJ} java_*.h ifeq (${METAVM}, yes) ${RM} -f ${JARFILE} diff -aruN shujit-0.3.12/README shujit/README --- shujit-0.3.12/README Sun Oct 10 15:37:07 1999 +++ shujit/README Sat Oct 16 19:25:33 1999 @@ -13,8 +13,9 @@ Working on the following platforms is confirmed. - Linux + - JDK 1.2 pre-release 2, egcs 1.1.2, glibc2.1.1 and Linux 2.2.12 - JDK 1.2 pre-release 2, egcs 1.0.3, glibc2.0.7 and Linux 2.2.12 - - JDK 1.1.7v3, egcs 1.0.3, glibc2.0.7 and Linux 2.2.12 + - JDK 1.1.7v3, egcs 1.1.2, glibc2.1.1 and Linux 2.2.12 - JDK 1.1.7v1a, egcs 1.1.2, libc5.4.38 and Linux 2.0.35 - FreeBSD diff -aruN shujit-0.3.12/code.c shujit/code.c --- shujit-0.3.12/code.c Sun Oct 10 20:36:02 1999 +++ shujit/code.c Sat Oct 16 18:24:33 1999 @@ -2146,13 +2146,14 @@ asm("popl %eax\n\t" /* eax = v1[0:31] */\ "popl %edi"); /* edi = v1[32:63] */\ FUNCCALL_IN(0);\ - asm("pushl %ebp\n\t"); /* back up for signal handler */\ + asm("pushl %esi\n\t"\ + "pushl %ebp\n\t"); /* back up for signal handler */\ asm("pushl " #OPTOP2_REG "\n\t" /* push v2[32:63] */\ "pushl " #OPTOP1_REG "\n\t" /* push v2[0:31] */\ "pushl %edi\n\t" /* push v1[32:63] */\ "pushl %eax\n\t" /* push v1[0:31] */\ "call " ROP "@PLT\n\t"\ - "addl $20,%esp");\ + "addl $24,%esp");\ asm(/* movl %edx,%edx */\ "movl %eax,%ecx");\ FUNCCALL_OUT(0) diff -aruN shujit-0.3.12/code.h shujit/code.h --- shujit-0.3.12/code.h Sat Aug 21 16:47:46 1999 +++ shujit/code.h Sat Oct 16 18:22:55 1999 @@ -99,9 +99,15 @@ /* This code must not use %esi which is the base of local variables */ #if defined(linux) -# define PUSH_STDOUT \ +# if !defined(__GLIBC__) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)) +# define PUSH_STDOUT \ asm("movl _IO_stdout_@GOT(%ebx),%eax\n\t"\ "pushl %eax"); +# else +# define PUSH_STDOUT \ + asm("movl stdout@GOT(%ebx),%eax\n\t"\ + "pushl (%eax)"); +# endif /* __GLIBC__ */ #elif defined(__FreeBSD__) # define PUSH_STDOUT \ asm("movl " SYMBOL(__sF) "@GOT(%ebx),%eax\n\t"\ diff -aruN shujit-0.3.12/compile.c shujit/compile.c --- shujit-0.3.12/compile.c Sun Oct 10 15:53:25 1999 +++ shujit/compile.c Sat Oct 16 16:52:00 1999 @@ -750,21 +750,6 @@ struct methodblock *src_mb; int fb_access; ClassClass *fb_class; - switch (opcode) { - case opc_getfield_quick: case opc_getfield2_quick: - case opc_getstatic_quick: case opc_getstatic2_quick: - case opc_putfield_quick: case opc_putfield2_quick: - case opc_putstatic_quick: case opc_putstatic2_quick: - /* NOTREACHED */ -#ifdef COMPILE_DEBUG - printf( - "quick field access insn(0x%x,%d). found." - " cannot get an index of constant pool.\n", opcode, opcode); - fflush(stdout); -#endif - break; - } - /* the field must be already resolved above */ index = GET_UINT16(bytepc + 1); fb = constant_pool[index].fb; diff -aruN shujit-0.3.12/compiler.c shujit/compiler.c --- shujit-0.3.12/compiler.c Mon Oct 4 14:00:42 1999 +++ shujit/compiler.c Sat Oct 16 18:52:34 1999 @@ -352,6 +352,9 @@ #ifdef SA_RESTART sigActForHandler.sa_flags |= SA_RESTART; #endif +#ifdef SA_ONSTACK + sigActForHandler.sa_flags &= ~SA_ONSTACK; /* not needed. */ +#endif #ifdef SA_RESETHAND sigActForHandler.sa_flags |= SA_RESETHAND; #endif @@ -687,7 +690,7 @@ printf("sc_offset(%d) is obsolete, search.\n", sc_offset); fflush(stdout); #endif -#define SC_SEARCH_WIDTH 50 +#define SC_SEARCH_WIDTH 100 for (sc_offset = 0; sc_offset < SC_SEARCH_WIDTH; sc_offset++) { # ifdef __FreeBSD__ if ( (((SIGCONTEXT *)ptr)->SC_GS & 0xffff == reg_gs) && @@ -744,23 +747,20 @@ #else codeinfo = (CodeInfo *)(mb->CompiledCodeInfo); tentry = throwtableGet(codeinfo, native_off); + +#define IP_SEARCH_COUNT 3 + if (!tentry) { /* search EIP in native code */ + uint32_t *ebp; + int i; #if defined(RUNTIME_DEBUG) || defined(COMPILE_DEBUG) - printf("throwentry: "); - fflush(stdout); - if (tentry) - printf("start: 0x%x, len: 0x%x, byteoff: 0x%x\n", - tentry->start, tentry->len, tentry->byteoff); - else - printf("(null)\n"); - fflush(stdout); + printf("throwentry is null !\n"); fflush(stdout); #endif /* RUNTIME_DEBUG || COMPILE_DEBUG */ -#define IP_SEARCH_WIDTH 50 - if (!tentry) { /* search EIP in native code */ - uint32_t *sp = (uint32_t *)sc->SC_ESP; - uint32_t *bound = sp + IP_SEARCH_WIDTH; + ebp = (uint32_t *)sc->SC_EBP; + + for (i = 0; i < IP_SEARCH_COUNT; i++) { + uint32_t *sp = ebp + 1; - while (++sp <= bound) { native_off = *sp - (uint32_t)mb->CompiledCode; if ((native_off >= 0) && (native_off <= codeinfo->code_size)) { tentry = throwtableGet(codeinfo, native_off); @@ -778,10 +778,21 @@ goto tentry_is_found; } } - } + ebp = (uint32_t *)*ebp; + } /* for (i = 0; i < IP_SEARCH_COUNT; ... */ goto signal_handler_error; tentry_is_found: } +#if defined(RUNTIME_DEBUG) || defined(COMPILE_DEBUG) + printf("throwentry: "); + fflush(stdout); + if (tentry) + printf("start: 0x%x, len: 0x%x, byteoff: 0x%x\n", + tentry->start, tentry->len, tentry->byteoff); + else + printf("(null)\n"); + fflush(stdout); +#endif /* RUNTIME_DEBUG || COMPILE_DEBUG */ #ifdef NULLEXC_BY_SIGNAL if (sig == SIGSEGV) { @@ -822,7 +833,10 @@ } else if ((tentry->opcode == opc_ldiv) || (tentry->opcode == opc_lrem)) { uint32_t *sp = (uint32_t *)sc->SC_ESP; - sc->SC_EBP = *(sp + 4); /* *(sp + 4) is %ebp `back up'ed in ldiv */ + sc->SC_ESP += 24; + /* `back up'ed registers in ldiv */ + sc->SC_EBP = *(sp + 4); /* *(sp + 4) is %ebp */ + sc->SC_ESI = *(sp + 5); /* *(sp + 5) is %esi */ /* dividend: (*(sp + 1) << 32) | *sp divisor : (*(sp + 3) << 32) | *(sp + 2) */ @@ -832,9 +846,10 @@ SignalError(NULL, JAVAPKG "ArithmeticException", "/ by zero"); } #if 0 - /* functions called by ldiv (__divdi3(),__moddi3()) don't cause SIGFPE */ + /* In this case, + functions called by ldiv (__divdi3(),__moddi3()) don't cause SIGFPE */ else if ((*sp == 0) && (*(sp + 1) == 0x80000000) && - ((*(sp +2) & *(sp + 3)) == 0xffffffff)) { + ((*(sp +2) & *(sp + 3)) == 0xffffffff)) { } #endif } diff -aruN shujit-0.3.12/compiler.h shujit/compiler.h --- shujit-0.3.12/compiler.h Sun Oct 10 20:27:49 1999 +++ shujit/compiler.h Sat Oct 16 17:30:38 1999 @@ -290,6 +290,7 @@ # define monitorExit2(EE, KEY) monitorExit(KEY) # define JVM_LoadLibrary(NAME) sysAddDLSegment(NAME) # define JVM_Exit(CODE) sysExit(CODE) +# define pExecuteJava ExecuteJava enum { TERSE_SIG_END = 0, TERSE_SIG_OBJECT, TERSE_SIG_LONG, TERSE_SIG_DOUBLE, TERSE_SIG_BOOLEAN, diff -aruN shujit-0.3.12/invoker.c shujit/invoker.c --- shujit-0.3.12/invoker.c Sun Oct 10 19:03:01 1999 +++ shujit/invoker.c Sat Oct 16 18:25:57 1999 @@ -195,7 +195,7 @@ fflush(stdout); } #endif - exec_ret = ExecuteJava(mb->code, ee); + exec_ret = pExecuteJava(mb->code, ee); #ifdef RUNTIME_DEBUG if (runtime_debug) { printf("ExecJava done(invoker.c): %s#%s.\n", diff -aruN shujit-0.3.12/runtime.c shujit/runtime.c --- shujit-0.3.12/runtime.c Thu Sep 9 04:37:01 1999 +++ shujit/runtime.c Sat Oct 16 17:30:47 1999 @@ -803,7 +803,7 @@ fflush(stdout); } #endif - exec_ret = ExecuteJava(method->code, ee); + exec_ret = pExecuteJava(method->code, ee); #ifdef RUNTIME_DEBUG if (runtime_debug) { printf("ExecuteJava(runtime.c) done: %s#%s.\n", diff -aruN shujit-0.3.12/txt/memo shujit/txt/memo --- shujit-0.3.12/txt/memo Sun Oct 10 17:17:31 1999 +++ shujit/txt/memo Sat Oct 16 18:12:52 1999 @@ -144,9 +144,11 @@ 移植時の注意 - self modify 時の offset new, invokestatic, {get,put}static{,2} - - 関数名シンボルが funcname か _funcname か。 - gentable.rb の挙動を変える。 - dynamic link 関係 + - 関数名シンボルが funcname か _funcname か。 + gentable.rb の挙動を変える。 + - stdout の libc 中のシンボル。 + _IO_stdout だったり stdout だったり… - Linux のように、dlopen(..., RTLD_LAZY) なライブラリ中の 関数のアドレスを関数実行前に得られるか、FreeBSD のように得られないか。 ^- この性質に依存しないコードにした。