diff -aruN shujit-0.2.9a/ChangeLog shujit/ChangeLog --- shujit-0.2.9a/ChangeLog Sun Feb 14 22:35:59 1999 +++ shujit/ChangeLog Tue Feb 23 22:49:31 1999 @@ -1,5 +1,37 @@ $Id$ +[19990223] + +ライブラリを sysAddDLSegment() する仕組みを変更した。 +FreeBSD のみ libc, libm の sysAddDLSegment() をハードコードしていたところ、 +より generic な仕組みにし、さらに環境変数で変更できるようにした。 +デフォルトで FreeBSD 4.0-current に対応した。 +(compiler.c, compiler.h) + +JITDO を遠隔オブジェクトに対する monitorenter, monitorexit に対応させた。 +(code.c, Protocol.java, Proxy.java, RequestServer.java, proxy.c, + +0.2.10 リリース。 +IGNORE_DISABLE は #undef に戻した。 + +[19990222] + +JITDO をきちんと動作させることができた。 + +[19990221] + +checkcast, instanceof 命令の pre-assembled code に +ClassClass * を書き込む回数を 1回にした。 +(code.c, compile.c) + +[19990220] + +invoke* 命令の pre-assembled code 中で、ecx と edi の役割を入れ換えた。 +(code.c) + +JITDO まわりを大幅に変更。 +(code.c) + [19990214] ファイル頭の copyright 表示もきちんと GPL のものにした。 @@ -10,6 +42,10 @@ 呼び出し時点のスタックポインタを push するのではなく、 native code で局所変数のベースを計算しておいてそれを push するようにした。 (code.c, runtime.c) + +0.2.9a リリース。 +0.2.9 で #define IGNORE_DISABLE としただけ。java Linpack の結果が良いので。 +jre Linpack での結果は #undef の方が良い。不思議。 [19990210] diff -aruN shujit-0.2.9a/GNUmakefile shujit/GNUmakefile --- shujit-0.2.9a/GNUmakefile Thu Feb 11 06:30:14 1999 +++ shujit/GNUmakefile Tue Feb 23 22:35:10 1999 @@ -40,7 +40,7 @@ ifdef JITDO SUBDIR += NET/shudo/jitdo jitdo OBJ += jitdo/objectid.o jitdo/vmop.o jitdo/controller.o \ - jitdo/proxy.o jitdo/copyable.o + jitdo/proxy.o jitdo/copyable.o jitdo/type.o NOOPTCFLAGS += -DJITDO CFLAGS += -DJITDO endif @@ -55,7 +55,7 @@ subdir: ifdef SUBDIR @for subdir in ${SUBDIR}; do \ - (cd $$subdir && $(MAKE)) \ + (cd $$subdir && $(MAKE) all CFLAGS="${CFLAGS}") \ done endif diff -aruN shujit-0.2.9a/code.c shujit/code.c --- shujit-0.2.9a/code.c Sun Feb 14 23:08:45 1999 +++ shujit/code.c Tue Feb 23 22:59:01 1999 @@ -309,6 +309,12 @@ /* exception handler */ CODE(opc_exception_handler, exception_handler, STANY, STSTA, 0) { +#ifdef JITDO + /* clear remote flag */ + asm("movl %0,%%edi\n\t" + "movb $0," EE_REMOTE_FLAG(%%edi) + : : "m" (ee)); +#endif #ifdef RUNTIME_DEBUG asm("pushl %0" : : "m" (runtime_debug)); #endif @@ -3222,10 +3228,12 @@ /* eax = index */ #ifdef JITDO -# define JITDO_GETFIELD(HANDLE, TGT, LABEL) \ +# define JITDO_GETFIELD(HANDLE, TGT, LABEL, STATE) \ JUMP_IF_NOT_REMOTE(LABEL "_local");\ JUMP_IF_NOT_PROXY(HANDLE, LABEL "_local");\ \ + FUNCCALL_IN(STATE);\ + \ asm("pushl %eax\n\t" /* slot */\ "pushl " #HANDLE); /* obj (Proxy) */\ asm("pushl %0" : : "m" (ee)); /* ee */\ @@ -3237,54 +3245,57 @@ "jmp " LABEL "_remoteget_done\n\t"\ LABEL "_obj:\n\t"\ "call " SYMBOL(proxy_getobjfield) "@PLT\n\t"\ - LABEL "_remoteget_done:\n\t"\ -); DEBUG_IN;\ + LABEL "_remoteget_done:");\ + asm("addl $12,%esp");\ + \ + FUNCCALL_OUT(STATE);\ +DEBUG_IN;\ asm("pushl %eax");\ PUSH_CONSTSTR("JITDO_GETFIELD: 0x%08x\n");\ -asm("call printf@PLT\n\t"\ +asm("call " SYMBOL(printf) "@PLT\n\t"\ "addl $8,%esp");\ FFLUSH;\ -DEBUG_OUT; asm(\ - "addl $12,%esp\n\t"\ - "movl %eax," #TGT "\n\t"\ +DEBUG_OUT;\ + \ + asm("movl %eax," #TGT "\n\t"\ "jmp " LABEL "_done\n\t"\ LABEL "_local:") #else -# define JITDO_GETFIELD(HANDLE, TGT, LABEL) +# define JITDO_GETFIELD(HANDLE, TGT, LABEL, STATE) #endif /* JITDO */ CODE(opc_getfield, getfield, ST0, ST3, 1) { asm("popl %edx"); /* now state 1 */ FIELD_ACC(%edx, getfield, 0); - JITDO_GETFIELD(%edx, %ecx, "getfield_st0"); + JITDO_GETFIELD(%edx, %ecx, "getfield_st0", 0); OBJ_GETSLOT(%edx, %eax, %ecx); asm("getfield_st0_done:"); ILOAD_DEBUG1(%ecx); } CODE(opc_getfield, getfield, ST1, ST3, 1) { FIELD_ACC(%edx, getfield, 1); - JITDO_GETFIELD(%edx, %ecx, "getfield_st1"); + JITDO_GETFIELD(%edx, %ecx, "getfield_st1", 0); OBJ_GETSLOT(%edx, %eax, %ecx); asm("getfield_st1_done:"); ILOAD_DEBUG1(%ecx); } CODE(opc_getfield, getfield, ST2, ST2, 1) { FIELD_ACC(%ecx, getfield, 2); - JITDO_GETFIELD(%ecx, %ecx, "getfield_st2"); + JITDO_GETFIELD(%ecx, %ecx, "getfield_st2", 1); OBJ_GETSLOT(%ecx, %eax, %ecx); asm("getfield_st2_done:"); ILOAD_DEBUG1(%ecx); } CODE(opc_getfield, getfield, ST3, ST1, 1) { FIELD_ACC(%ecx, getfield, 3); - JITDO_GETFIELD(%ecx, %edx, "getfield_st3"); + JITDO_GETFIELD(%ecx, %edx, "getfield_st3", 0); OBJ_GETSLOT(%ecx, %eax, %edx); asm("getfield_st3_done:"); ILOAD_DEBUG1(%edx); } CODE(opc_getfield, getfield, ST4, ST4, 1) { FIELD_ACC(%edx, getfield, 4); - JITDO_GETFIELD(%edx, %edx, "getfield_st4"); + JITDO_GETFIELD(%edx, %edx, "getfield_st4", 3); OBJ_GETSLOT(%edx, %eax, %edx); asm("getfield_st4_done:"); ILOAD_DEBUG1(%edx); @@ -3411,7 +3422,7 @@ # define JITDO_PUTFIELD2(HANDLE, VAL_LOW, VAL_HIGH, LABEL) \ asm("pushl %eax\n\tpushl %edi"); /* save */\ JUMP_IF_NOT_REMOTE(LABEL "_local");\ - asm("movl (%esp),%eax"); /* %eax = TOS(%edi) */\ + asm("movl (%esp),%eax"); /* %eax = TOS (%edi) */\ JUMP_IF_NOT_PROXY(%eax, LABEL "_local"); /* 1st arg must not be %edi */\ asm("popl %edi\n\tpopl %eax"); /* restore */\ \ @@ -3422,8 +3433,8 @@ asm("pushl %0" : : "m" (ee)); /* ee */\ \ asm("call " SYMBOL(proxy_put64field) "@PLT\n\t"\ - "addl $20,%esp\n\t"\ - "jmp " LABEL "_done\n\t"\ + "addl $20,%esp");\ + asm("jmp " LABEL "_done\n\t"\ LABEL "_local:\n\t"\ "popl %edi\n\tpopl %eax") /* restore */ #else @@ -3436,7 +3447,7 @@ FIELD_ACC(%edi, putfield2, STATE);\ JITDO_PUTFIELD2(%edi, OPTOP1_REG, OPTOP2_REG, "putfield2_st" #STATE);\ OBJ_SETSLOT2(%edi, %eax, OPTOP1_REG, OPTOP2_REG);\ - asm("putfild2_st" #STATE "_done:") + asm("putfield2_st" #STATE "_done:") CODE(opc_putfield2, putfield2, ST0, ST0, 1) { asm("popl %ecx\n\t" @@ -3490,19 +3501,25 @@ # define CALL_INVOKEHELPER_FUNC \ asm("pushl %0" : : "m" (runtime_debug));\ asm("call " SYMBOL(invocationHelper) "@PLT");\ + \ + asm("movl 12(%esp),%ecx"); /* restore args_size */\ + \ asm("addl $32,%esp") #else # define CALL_INVOKEHELPER_FUNC \ asm("call " SYMBOL(invocationHelper) "@PLT");\ + \ + asm("movl 8(%esp),%ecx"); /* restore args_size */\ + \ asm("addl $28,%esp") #endif #define CALL_INVOKEHELPER(LABEL) \ asm("pushl %0" : : "m" (bytepcoff));/* bytepcoff */\ asm("pushl $" STR(CONST)); /* retsize */\ - asm("pushl %ecx"); /* origianl esp */\ + asm("pushl %edi"); /* origianl esp */\ asm("pushl %0" : : "m" (ee)); /* ee */\ - asm("pushl %edi\n\t" /* args_size */\ + asm("pushl %ecx\n\t" /* args_size */\ "pushl %eax\n\t" /* method */\ "pushl %edx"); /* obj */\ CALL_INVOKEHELPER_FUNC;\ @@ -3511,17 +3528,18 @@ #define INVOKE_RESTACK(LABEL) \ /* restack\ eax: return value from invocationHelper()\ - edi: arg_size */\ + ecx: arg_size */\ \ asm(LABEL "_restack:");\ /* adjust optop */\ - asm("leal (%esp,%edi,4),%esp"); /* esp += (args_size * 4) */\ + asm("leal (%esp,%ecx,4),%esp"); /* esp += (args_size * 4) */\ /* if (eax < 0) goto exception_handler */\ asm("testl %eax,%eax\n\t"\ "jl " STR(ADDR_EXC));\ \ asm("jz " LABEL "_done"); /* if (ret_size == 0) done */\ \ + /* Now we can break edi, edx and ecx ! */\ /* edi = ee->current_frame->optop */\ {\ register ExecEnv *cur_ee asm("edi");\ @@ -3547,51 +3565,52 @@ #ifdef JITDO # define JITDO_INVOKE(LABEL) \ - asm("movl %esp,%ecx"); /* save %esp to %ecx */\ - \ - asm("pushl %edi"); /* save */\ - JUMP_IF_NOT_REMOTE(LABEL "_local");\ - JUMP_IF_NOT_PROXY(%edx /* is obj */, LABEL "_local");\ + JUMP_IF_NOT_REMOTE(LABEL "_inv_local");\ + JUMP_IF_NOT_PROXY(%edx /* is obj */, LABEL "_inv_local");\ + /* these break edi */\ \ /* call Proxy#* at local */\ - asm("pushl %eax"); /* save */\ + asm("pushl %ecx\n\tpushl %eax\n\t" /* save */\ + "leal 8(%esp),%ecx"); /* save original esp to ecx */\ + \ METHOD_CLAZZ(%eax,%eax);\ - CB_METHODTABLE(%eax,%eax);\ - asm("movl " SYMBOL(proxy_methodtable) "@GOT(%ebx),%edi");\ - asm("movl (%edi),%edi");\ + CB_METHODTABLE(%eax,%eax); /* break edi */\ + /* eax = cbMethodTable(mb->fb.clazz) */\ + METHODTABLE_OF_PROXY(%edi);\ + /* edi = cbMethodTable(Proxy clazz) */\ DEBUG_IN;\ asm("pushl %edi\n\tpushl %eax");\ PUSH_CONSTSTR("eax: 0x%08x, edi: 0x%08x\n");\ -asm("call printf@PLT\n\t"\ - "addl $12,%esp");\ +asm("call " SYMBOL(printf) "@PLT\n\t"\ + "addl $12,%esp");\ FFLUSH;\ DEBUG_OUT;\ - asm("cmpl %eax,%edi\n\t"\ - "popl %eax\n\t" /* restore */\ - "jz " LABEL "_local");\ + asm("cmpl %eax,%edi");\ + asm("jnz " LABEL "_inv_remote\n\t"\ + "popl %eax\n\tpopl %ecx\n\t" /* restore */\ + "jmp " LABEL "_inv_local");\ \ - asm("pushl %esi");\ + asm(LABEL "_inv_remote:\n\t"\ + "popl %eax"); /* restore */\ \ asm("pushl %ecx\n\t" /* stack pointer */\ "pushl " METHOD_SIGNATURE(%eax) "\n\t"\ "pushl " METHOD_NAME(%eax) "\n\t"\ - "pushl %edx"); /* obj (Proxy) */\ + "pushl %edx"); /* obj (Proxy) */\ asm("pushl %0" : : "m" (ee)); /* ee */\ asm("call " SYMBOL(proxy_invoke) "@PLT\n\t"\ "addl $20,%esp");\ \ - asm("popl %esi\n\tpopl %edi");\ - /* %eax: ret_size, %edi: args_size */\ + asm("popl %ecx"); /* restore */\ + asm("jmp " LABEL "_restack");\ \ - asm("jmp " LABEL "_restack\n\t"\ - LABEL "_local:");\ - asm("popl %edi") /* restore */ + asm(LABEL "_inv_local:") #else # define JITDO_INVOKE(LABEL) #endif /* JITDO */ #define INVOKE_ST0(VOP, LABEL) \ - asm("movl $" STR(CONST) ",%edi"); /* edi = args_size */\ + asm("movl $" STR(CONST) ",%ecx"); /* ecx = args_size */\ bytepcoff = BYTEPCOFF;\ \ TGTOBJ_##VOP(LABEL, 0); /* edx = obj */\ @@ -3601,23 +3620,19 @@ \ JITDO_INVOKE_##VOP(LABEL);\ \ - VARSPACE_##VOP(LABEL); /* ecx = local var. space */\ + VARSPACE_##VOP(LABEL); /* edi = local var. space */\ + \ + asm("subl %edi,%esp\n\t"\ + "pushl %edi\n\t" /* save */\ + "leal 4(%esp,%edi),%edi"); /* edi = original esp */\ \ - asm("subl %ecx,%esp\n\t"\ - "pushl %ecx\n\t"\ - "leal 4(%esp,%ecx),%ecx"); /* ecx = original esp */\ - \ - asm("leal -4(%ecx,%edi,4),%ecx");\ - /* ecx = original esp + 4 * (args_size - 1) */\ - \ - /*\ - asm("leal -4(%ecx,%edi,4),%ecx");\ - /* ecx = original esp + (args_size * 4 - 1) */\ + asm("leal -4(%edi,%ecx,4),%edi");\ + /* edi = original esp + 4 * (args_size - 1) */\ \ CALL_INVOKEHELPER(LABEL);\ \ - asm("popl %ecx"); /* free local var space */\ - asm("addl %ecx,%esp");\ + asm("popl %edi"); /* restore */\ + asm("addl %edi,%esp"); /* free local var space */\ \ INVOKE_RESTACK(LABEL) @@ -3647,73 +3662,70 @@ #define TGTOBJ_VIRTUAL(LABEL, STATE) \ - asm("movl -4(%esp,%edi,4),%edx");\ + asm("movl -4(%esp,%ecx,4),%edx");\ NULL_TEST(%edx, LABEL, STATE) #ifdef JITDO # define METHODBLOCK_VIRTUAL(LABEL) \ - asm("pushl %edi"); /* save */\ - OBJ_ARRAY_METHODTABLE(%edx, %ecx, LABEL); /* ecx = obj_array_..(obj) */\ - /* debug code */\ + OBJ_ARRAY_METHODTABLE(%edx, %eax, LABEL); /* eax = obj_array_..(obj) */\ \ - JUMP_IF_NOT_REMOTE(LABEL "_not_proxy");\ + JUMP_IF_NOT_REMOTE(LABEL "_not_proxy"); /* break edi */\ \ METHODTABLE_OF_PROXY(%edi);\ - asm("cmpl %ecx,%edi\n\t"\ + asm("cmpl %eax,%edi\n\t"\ "jnz " LABEL "_not_proxy");\ DEBUG_IN;\ PUSH_CONSTSTR("METDODBLOCK_VIRTUAL: Proxy is found.\n");\ -asm("call printf@PLT\n\t"\ - "addl $4,%esp");\ +asm("call " SYMBOL(printf) "@PLT\n\t"\ + "addl $4,%esp");\ FFLUSH;\ DEBUG_OUT;\ - PROXY_CLAZZ(%edx, %ecx); /* ecx = Proxy.clazz */\ + PROXY_CLAZZ(%edx, %eax); /* eax = Proxy.clazz */\ DEBUG_IN;\ -asm("pushl %ecx");\ -CB_NAME(%ecx, %ecx);\ -asm("pushl %ecx");\ +asm("pushl %eax");\ +CB_NAME(%eax, %eax);\ +asm("pushl %eax");\ PUSH_CONSTSTR(" Proxy.clazz: %s 0x%08x\n");\ -asm("call printf@PLT\n\t"\ - "addl $12,%esp");\ +asm("call " SYMBOL(printf) "@PLT\n\t"\ + "addl $12,%esp");\ FFLUSH;\ DEBUG_OUT;\ - CB_METHODTABLE(%ecx, %ecx); /* ecx = methodtable of Proxy.clazz*/\ + CB_METHODTABLE(%eax, %eax); /* eax = methodtable of Proxy.clazz */\ DEBUG_IN;\ -asm("pushl %ecx");\ +asm("pushl %eax");\ PUSH_CONSTSTR(" methodtable: 0x%08x\n");\ -asm("call printf@PLT\n\t"\ - "addl $8,%esp");\ +asm("call " SYMBOL(printf) "@PLT\n\t"\ + "addl $8,%esp");\ FFLUSH;\ DEBUG_OUT;\ \ asm(LABEL "_not_proxy:");\ - asm("popl %edi"); /* restore */\ - asm("movl $" STR(CONST) ",%eax"); /* eax = methodIndex */\ - MT_SLOT(%ecx, %eax, %eax) /* eax = method */ + asm("movl $" STR(CONST) ",%edi"); /* edi = methodIndex */\ + MT_SLOT(%eax, %edi, %eax) /* eax = method */ #else -#define METHODBLOCK_VIRTUAL(LABEL) \ +# define METHODBLOCK_VIRTUAL(LABEL) \ /* get methodblock */\ - OBJ_ARRAY_METHODTABLE(%edx, %ecx, LABEL); /* ecx = obj_array_..(obj) */\ - asm("movl $" STR(CONST) ",%eax"); /* eax = methodIndex */\ - MT_SLOT(%ecx, %eax, %eax) /* eax = method */ + OBJ_ARRAY_METHODTABLE(%edx, %eax, LABEL); /* eax = obj_array_..(obj) */\ + asm("movl $" STR(CONST) ",%edi"); /* edi = methodIndex */\ + MT_SLOT(%eax, %edi, %eax) /* eax = method */ #endif /* JITDO */ #define VARSPACE_VIRTUAL(LABEL) \ /* allocate local var space */\ - METHOD_NLOCALS(%eax, %ecx); /* ecx = method->nlocals */\ - asm("subl %edi,%ecx\n\t" /* ecx -= args_size */\ + METHOD_NLOCALS(%eax, %edi); /* edi = method->nlocals */\ + asm("subl %ecx,%edi\n\t" /* edi -= args_size */\ "jle " LABEL "_nlocal_le_0\n\t"\ - "shll $2,%ecx\n\t" /* ecx *= 4 */\ + "shll $2,%edi\n\t" /* edi *= 4 */\ "jmp " LABEL "_nlocal_done\n\t"\ LABEL "_nlocal_le_0:\n\t"\ - "xorl %ecx,%ecx\n\t" /* ecx = 0 */\ + "xorl %edi,%edi\n\t" /* edi = 0 */\ LABEL "_nlocal_done:") #define JITDO_INVOKE_VIRTUAL(LABEL) JITDO_INVOKE(LABEL) #define TGTOBJ_SPECIAL(LABEL, STATE) TGTOBJ_VIRTUAL(LABEL, STATE) #define METHODBLOCK_SPECIAL(LABEL) asm("movl $" STR(CONST) ",%eax") -#define VARSPACE_SPECIAL(LABEL) asm("movl $" STR(CONST) ",%ecx") +#define VARSPACE_SPECIAL(LABEL) asm("movl $" STR(CONST) ",%edi") #define JITDO_INVOKE_SPECIAL(LABEL) JITDO_INVOKE(LABEL) #define TGTOBJ_STATIC(LABEL, STATE) @@ -3721,14 +3733,14 @@ #define METHODBLOCK_STATIC(LABEL) \ asm("movl $" STR(CONST) ",%eax");\ METHOD_CLAZZ(%eax,%edx) /* edx = cbHandle(method->fb.clazz) */ -#define VARSPACE_STATIC(LABEL) asm("movl $" STR(CONST) ",%ecx") +#define VARSPACE_STATIC(LABEL) asm("movl $" STR(CONST) ",%edi") #define JITDO_INVOKE_STATIC(LABEL) /* nothing */ #define TGTOBJ_INTERFACE(LABEL, STATE) TGTOBJ_VIRTUAL(LABEL, STATE) #define METHODBLOCK_INTERFACE(LABEL) \ /* get methodblock: call getInterfaceMethod() */\ - asm("pushl %edi\n\tpushl %edx");\ + asm("pushl %ecx\n\tpushl %edx"); /* save */\ FUNCCALL_IN(0);\ asm("pushl $" STR(CONST) "\n\t" /* guessptr */\ "pushl $" STR(CONST) "\n\t" /* imethod */\ @@ -3736,7 +3748,7 @@ asm("pushl %0" : : "m" (ee)); /* ee */\ CALL_GETINTFMETHOD;\ FUNCCALL_OUT(0);\ - asm("popl %edx\n\tpopl %edi") + asm("popl %edx\n\tpopl %ecx") /* save */ #define VARSPACE_INTERFACE(LABEL) VARSPACE_VIRTUAL(LABEL) #define JITDO_INVOKE_INTERFACE(LABEL) JITDO_INVOKE(LABEL) @@ -3858,10 +3870,7 @@ # define JITDO_NEW(CB_REG, DST_REG, LABEL, STATE) \ JUMP_IF_NOT_REMOTE(LABEL "_local");\ \ - { /* %edi = ee */\ - register ExecEnv *cur_ee asm("edi");\ - cur_ee = ee;\ - }\ + asm("movl %0,%%edi" : : "m" (ee)); /* edi = ee*/\ \ /* local operation if remote VM addr is null */\ asm("movl " EE_REMOTE_ADDR(%edi) ",%eax\n\t"\ @@ -3869,15 +3878,13 @@ "jz " LABEL "_local");\ \ /* call isCopyable() */\ - asm("pushl %edi");\ FUNCCALL_IN(STATE);\ asm("pushl " #CB_REG "\n\t"\ "pushl %edi\n\t"\ "call " SYMBOL(isCopyable) "@PLT");\ - asm("addl $4,%esp\n\t"\ + asm("popl %edi\n\t"\ "popl " #CB_REG);\ FUNCCALL_OUT(STATE);\ - asm("popl %edi");\ asm("testl %eax,%eax\n\t"\ "jnz " LABEL "_local");\ \ @@ -3887,30 +3894,38 @@ "pushl " EE_REMOTE_ADDR(%edi) "\n\t"\ "pushl %edi\n\t" /* ee */\ "call " SYMBOL(proxy_new) "@PLT\n\t"\ - "addl $12,%esp");\ + "popl %edi\n\t" /* edi = ee */\ + "addl $8,%esp");\ FUNCCALL_OUT(STATE);\ \ JUMP_IF_EXC_HASNT_OCCURRED(%edi /* is ee */, LABEL "_done");\ +DEBUG_IN;\ +PUSH_CONSTSTR("JITDO_NEW exc. occurred.\n");\ +asm("call " SYMBOL(printf) "@PLT\n\t"\ + "addl $4,%esp");\ +FFLUSH;\ +DEBUG_OUT;\ SIGNAL_ERROR_JUMP(STATE);\ - asm("jmp " LABEL "_done\n\t"\ - LABEL "_local:") +DEBUG_IN;\ +PUSH_CONSTSTR("didn't jump to exc. handler ???.\n");\ +asm("call " SYMBOL(printf) "@PLT\n\t"\ + "addl $4,%esp");\ +FFLUSH;\ +DEBUG_OUT;\ + asm(LABEL "_local:") #else # define JITDO_NEW(CB_REG, DST_REG, LABEL, STATE) #endif /* JITDO */ /* stuff to rewrite code */ -#if defined(linux) -# ifdef RUNTIME_DEBUG -# define NEW_REWRITE_OFFSET_0 0x32 -# else -# define NEW_REWRITE_OFFSET_0 5 -# endif -#elif defined(__FreeBSD__) -# ifdef RUNTIME_DEBUG -# define NEW_REWRITE_OFFSET_0 0x37 -# else -# define NEW_REWRITE_OFFSET_0 5 +#ifdef RUNTIME_DEBUG +# if defined(linux) +# define NEW_REWRITE_OFFSET_0 0x31 +# elif defined(__FreeBSD__) +# define NEW_REWRITE_OFFSET_0 0x34 # endif +#else +# define NEW_REWRITE_OFFSET_0 5 #endif # define NEW_REWRITE_OFFSET_1 NEW_REWRITE_OFFSET_0 @@ -4149,19 +4164,25 @@ /* const: cb */ #ifdef JITDO # define JITDO_CHECKCAST(OPTOP1_REG, LABEL, STATE) \ + FUNCCALL_IN(STATE);\ + asm("pushl %eax\n\t" /* cb */\ + "call " SYMBOL(isCheckPassType) "@PLT\n\t"\ + "testl %eax,%eax\n\t"\ + "popl %eax");\ + FUNCCALL_OUT(STATE);\ + asm("jnz " LABEL "_true");\ + \ /* compare handle->methods with cb_of_Proxy->methodtable */\ JUMP_IF_NOT_REMOTE(LABEL "_local");\ - JUMP_IF_NOT_PROXY(%##OPTOP1_REG, LABEL "_local");\ + JUMP_IF_NOT_PROXY(OPTOP1_REG, LABEL "_local");\ {\ - register HNET_shudo_jitdo_Proxy *h asm(#OPTOP1_REG);\ register ClassNET_shudo_jitdo_Proxy *edi asm("edi");\ - register Hjava_lang_Class *clz asm("eax");\ + register Hjava_lang_Class *clz asm("edi");\ \ - edi = unhand(h);\ + UNHAND(OPTOP1_REG, %edi);\ clz = edi->clazz;\ - } /* eax = Proxy.clazz */\ - asm("movl $" STR(CONST) ",%edi\n\t" /* cb */\ - "cmpl %eax,%edi\n\t"\ + } /* edi = Proxy.clazz */\ + asm("cmpl %eax,%edi\n\t"\ "jnz " LABEL "_fail\n\t"\ "jmp " LABEL "_done\n\t"\ LABEL "_local:"); @@ -4170,13 +4191,14 @@ #endif /* JITDO */ #define CHECKCAST(OPTOP1_REG, LABEL, STATE) \ - asm("testl %" #OPTOP1_REG ",%" #OPTOP1_REG "\n\t"\ + asm("testl " #OPTOP1_REG "," #OPTOP1_REG "\n\t"\ "jz " LABEL "_done");\ + asm("movl $" STR(CONST) ",%eax"); /* cb */\ JITDO_CHECKCAST(OPTOP1_REG, LABEL, STATE);\ FUNCCALL_IN(STATE);\ asm("pushl %0" : : "m" (ee)); /* ee */\ - asm("pushl $" STR(CONST) "\n\t" /* cb */\ - "pushl %" #OPTOP1_REG "\n\t"\ + asm("pushl %eax\n\t" /* cb */\ + "pushl " #OPTOP1_REG "\n\t"\ "call " SYMBOL(is_instance_of) "@PLT\n\t"\ "addl $12,%esp");\ FUNCCALL_OUT(STATE);\ @@ -4188,42 +4210,50 @@ CODE(opc_checkcast, checkcast, ST0, ST1, 0) { asm("popl %edx"); /* now state 1 */ - CHECKCAST(edx, "checkcast_st0", 1); + CHECKCAST(%edx, "checkcast_st0", 1); } CODE(opc_checkcast, checkcast, ST1, ST1, 0) { - CHECKCAST(edx, "checkcast_st1", 1); + CHECKCAST(%edx, "checkcast_st1", 1); } CODE(opc_checkcast, checkcast, ST2, ST2, 0) { - CHECKCAST(ecx, "checkcast_st2", 2); + CHECKCAST(%ecx, "checkcast_st2", 2); } CODE(opc_checkcast, checkcast, ST3, ST3, 0) { - CHECKCAST(ecx, "checkcast_st3", 3); + CHECKCAST(%ecx, "checkcast_st3", 3); } CODE(opc_checkcast, checkcast, ST4, ST4, 0) { - CHECKCAST(edx, "checkcast_st4", 4); + CHECKCAST(%edx, "checkcast_st4", 4); } /* instanceof */ /* const: cb */ #ifdef JITDO # define JITDO_INSTANCEOF(OPTOP1_REG, LABEL, STATE) \ + FUNCCALL_IN(STATE);\ + asm("pushl %eax\n\t" /* cb */\ + "call " SYMBOL(isCheckPassType) "@PLT\n\t"\ + "testl %eax,%eax\n\t"\ + "popl %eax");\ + FUNCCALL_OUT(STATE);\ + asm("jnz " LABEL "_true");\ + \ /* compare handle->methods with cb_of_Proxy->methodtable */\ - JUMP_IF_NOT_PROXY(%##OPTOP1_REG, LABEL "_local");\ + JUMP_IF_NOT_REMOTE(LABEL "_local");\ + JUMP_IF_NOT_PROXY(OPTOP1_REG, LABEL "_local");\ {\ - register HNET_shudo_jitdo_Proxy *h asm(#OPTOP1_REG);\ register ClassNET_shudo_jitdo_Proxy *edi asm("edi");\ - register Hjava_lang_Class *clz asm("eax");\ + register Hjava_lang_Class *clz asm("edi");\ \ - edi = unhand(h);\ + UNHAND(OPTOP1_REG, %edi);\ clz = edi->clazz;\ - } /* eax = Proxy.clazz */\ - asm("movl $" STR(CONST) ",%edi\n\t" /* cb */\ - "cmpl %eax,%edi\n\t"\ + } /* edi = Proxy.clazz */\ + asm("cmpl %eax,%edi\n\t"\ "jz " LABEL "_false\n\t"\ - "movl $1,%" #OPTOP1_REG "\n\t"\ + LABEL "_true:"\ + "movl $1," #OPTOP1_REG "\n\t"\ "jmp " LABEL "_done\n\t"\ LABEL "_false:"\ - "movl $0,%" #OPTOP1_REG "\n\t"\ + "movl $0," #OPTOP1_REG "\n\t"\ "jmp " LABEL "_done\n\t"\ LABEL "_local:"); #else @@ -4231,66 +4261,99 @@ #endif /* JITDO */ #define INSTANCEOF(OPTOP1_REG, LABEL, STATE) \ - asm("testl %" #OPTOP1_REG ",%" #OPTOP1_REG "\n\t"\ + asm("testl " #OPTOP1_REG "," #OPTOP1_REG "\n\t"\ "jz " LABEL "_done");\ + asm("movl $" STR(CONST) ",%eax"); /* cb */\ JITDO_INSTANCEOF(OPTOP1_REG, LABEL, STATE);\ FUNCCALL_IN(STATE);\ asm("pushl %0" : : "m" (ee)); /* ee */\ - asm("pushl $" STR(CONST) "\n\t"\ - "pushl %" #OPTOP1_REG "\n\t"\ + asm("pushl %eax\n\t" /* cb */\ + "pushl " #OPTOP1_REG "\n\t"\ "call " SYMBOL(is_instance_of) "@PLT\n\t"\ "addl $12,%esp");\ FUNCCALL_OUT(STATE);\ - asm("movl %eax,%" #OPTOP1_REG "\n\t"\ + asm("movl %eax," #OPTOP1_REG "\n\t"\ LABEL "_done:") CODE(opc_instanceof, instanceof, ST0, ST1, 0) { asm("popl %edx"); /* now state 1 */ - INSTANCEOF(edx, "instanceof_st0", 1); + INSTANCEOF(%edx, "instanceof_st0", 1); } CODE(opc_instanceof, instanceof, ST1, ST1, 0) { - INSTANCEOF(edx, "instanceof_st1", 1); + INSTANCEOF(%edx, "instanceof_st1", 1); } CODE(opc_instanceof, instanceof, ST2, ST2, 0) { - INSTANCEOF(ecx, "instanceof_st2", 2); + INSTANCEOF(%ecx, "instanceof_st2", 2); } CODE(opc_instanceof, instanceof, ST3, ST3, 0) { - INSTANCEOF(ecx, "instanceof_st3", 3); + INSTANCEOF(%ecx, "instanceof_st3", 3); } CODE(opc_instanceof, instanceof, ST4, ST4, 0) { - INSTANCEOF(edx, "instanceof_st4", 4); + INSTANCEOF(%edx, "instanceof_st4", 4); } /* monitorenter, monitorexit */ -#define MONITOR(OPTOP1_REG, FUNCNAME, LABEL, STATE) \ +#ifdef JITDO +# define JITDO_MONITOR(OPTOP1_REG, JITDO_FUNCNAME, LABEL, STATE) \ + JUMP_IF_NOT_REMOTE(LABEL "_local");\ + JUMP_IF_NOT_PROXY(OPTOP1_REG, LABEL "_local");\ + \ + FUNCCALL_IN(STATE);\ + \ + asm("movl %0,%%edi" : : "m" (ee)); /* edi = ee*/\ + \ + asm("pushl " #OPTOP1_REG "\n\t"\ + "pushl %edi\n\t"\ + "call " SYMBOL(JITDO_FUNCNAME) "@PLT\n\t"\ + "popl %edi\n\t" /* edi = ee */\ + "addl $4,%esp");\ + \ + FUNCCALL_OUT(STATE);\ + \ + JUMP_IF_EXC_HASNT_OCCURRED(%edi /* is ee */, LABEL "_done");\ +DEBUG_IN;\ +PUSH_CONSTSTR("JITDO_MONITOR exc. occurred.\n");\ +asm("call " SYMBOL(printf) "@PLT\n\t"\ + "addl $4,%esp");\ +FFLUSH;\ +DEBUG_OUT;\ + SIGNAL_ERROR_JUMP(STATE);\ + asm(LABEL "_local:") +#else +# define JITDO_MONITOR(OPTOP1_REG, JITDO_FUNCNAME, LABEL, STATE) +#endif /* JITDO */ + +#define MONITOR(OPTOP1_REG, FUNCNAME, JITDO_FUNCNAME, LABEL, STATE) \ NULL_TEST_CANT_BE_ELIMINATED(OPTOP1_REG, LABEL "_1", STATE);\ + JITDO_MONITOR(OPTOP1_REG, JITDO_FUNCNAME, LABEL, STATE);\ OBJ_MONITOR(OPTOP1_REG, OPTOP1_REG);\ FUNCCALL_IN(STATE);\ asm("pushl " #OPTOP1_REG "\n\t"\ - "call " #FUNCNAME "@PLT\n\t"\ + "call " SYMBOL(FUNCNAME) "@PLT\n\t"\ "addl $4,%esp");\ - FUNCCALL_OUT(STATE) + FUNCCALL_OUT(STATE);\ + asm(LABEL "_done:") -#define CODE_MONITOR(vop, FUNCNAME) \ +#define CODE_MONITOR(vop, FUNCNAME, JITDO_FUNCNAME) \ CODE(opc_##vop, ##vop, ST0, ST0, 1) {\ asm("popl %edx"); /* now state 1 */\ - MONITOR(%edx, FUNCNAME, #vop "_st0", 0);\ + MONITOR(%edx, FUNCNAME, JITDO_FUNCNAME, #vop "_st0", 0);\ }\ CODE(opc_##vop, ##vop, ST1, ST0, 1) {\ - MONITOR(%edx, FUNCNAME, #vop "_st1", 0);\ + MONITOR(%edx, FUNCNAME, JITDO_FUNCNAME, #vop "_st1", 0);\ }\ CODE(opc_##vop, ##vop, ST2, ST1, 1) {\ - MONITOR(%ecx, FUNCNAME, #vop "_st2", 1);\ + MONITOR(%ecx, FUNCNAME, JITDO_FUNCNAME, #vop "_st2", 1);\ }\ CODE(opc_##vop, ##vop, ST3, ST0, 1) {\ - MONITOR(%ecx, FUNCNAME, #vop "_st3", 0);\ + MONITOR(%ecx, FUNCNAME, JITDO_FUNCNAME, #vop "_st3", 0);\ }\ CODE(opc_##vop, ##vop, ST4, ST3, 1) {\ - MONITOR(%edx, FUNCNAME, #vop "_st4", 3);\ + MONITOR(%edx, FUNCNAME, JITDO_FUNCNAME, #vop "_st4", 3);\ } - CODE_MONITOR(monitorenter, monitorEnter); - CODE_MONITOR(monitorexit, monitorExit); + CODE_MONITOR(monitorenter, monitorEnter, proxy_monitorenter); + CODE_MONITOR(monitorexit, monitorExit, proxy_monitorexit); /* multianewarray */ /* const: dimensions, arrayclazz */ diff -aruN shujit-0.2.9a/code.h shujit/code.h --- shujit-0.2.9a/code.h Sun Feb 14 20:00:46 1999 +++ shujit/code.h Tue Feb 23 20:28:37 1999 @@ -65,10 +65,10 @@ * OS dependence */ -#if defined(linux) || (defined(sun) && defined(__svr4__)) -# define SYMBOL(SYM) STR(SYM) -#elif defined(__FreeBSD__) +#ifdef __FreeBSD__ # define SYMBOL(SYM) "_" STR(SYM) +#else +# define SYMBOL(SYM) STR(SYM) #endif #ifndef WIN32 @@ -201,15 +201,18 @@ #ifdef RUNTIME_DEBUG # define CODE_DEBUG(LABEL) \ + asm("pushl %eax\n\t"\ + "leal 4(%esp),%eax");\ DEBUG_IN;\ if (runtime_debug) {\ - asm("pushl %ebp");\ + asm("pushl %eax");\ PUSH_CONSTSTR(">" LABEL " %x\n");\ asm("call " SYMBOL(printf) "@PLT\n\t"\ "addl $8,%esp");\ FFLUSH;\ }\ - DEBUG_OUT; + DEBUG_OUT;\ + asm("popl %eax") #else # define CODE_DEBUG(LABEL) #endif @@ -247,15 +250,15 @@ asm("movl 4(" #HANDLE ")," #DST) #define OBJ_ARRAY_METHODTABLE(HANDLE, DST, LABEL) \ asm("movl 4(" #HANDLE ")," #DST "\n\t"\ - "movl " #DST ",%eax\n\t"\ - "andl $31,%eax\n\t"\ - "cmpl $" STR(T_NORMAL_OBJECT) ",%eax\n\t"\ + "movl " #DST ",%edi\n\t"\ + "andl $31,%edi\n\t"\ + "cmpl $" STR(T_NORMAL_OBJECT) ",%edi\n\t"\ "je " LABEL "_mtdone");\ asm("movl %0,%" #DST : : "m" (classJavaLangObject));\ - asm("movl (" #DST "),%eax\n\t"\ - "movl 48(%eax)," #DST);\ + asm("movl (" #DST ")," #DST "\n\t"\ + "movl 48(" #DST ")," #DST);\ asm(LABEL "_mtdone:") - /* destroy %eax */ + /* destroy %edi, DST can't be %edi */ #define MT_SLOT(MTBL, SLOT, DST) \ asm("movl 4(" #MTBL "," #SLOT ",4)," #DST) @@ -307,13 +310,6 @@ #define EE_CURRENTFRAME(EE) "4(" #EE ")" #define EE_EXCEPTIONKIND(EE) "12(" #EE ")" -#define JUMP_IF_EXC_HASNT_OCCURRED(EE, LABEL) \ - asm("movl " EE_EXCEPTIONKIND(EE) ",%edi\n\t"\ - "testl %edi,%edi\n\t"\ - "jz " LABEL) -#define EXCEPTION_CLEAR(EE) \ - asm("movl $0," EE_EXCEPTIONKIND(EE)); - #define FRAME_OPTOP(FRAME) "8(" #FRAME ")" #define FRAME_VARS(FRAME) "12(" #FRAME ")" #define FRAME_PREV(FRAME) "16(" #FRAME ")" @@ -366,5 +362,10 @@ #define PROXY_CLAZZ(HANDLE, DST) \ UNHAND(HANDLE, DST);\ asm("movl 4(" #DST ")," #DST); + +#define JUMP_IF_EXC_HASNT_OCCURRED(EE, LABEL) \ + asm("movl " EE_EXCEPTIONKIND(EE) ",%edi");\ + asm("testl %edi,%edi\n\t"\ + "jz " LABEL) #endif /* JITDO */ diff -aruN shujit-0.2.9a/compile.c shujit/compile.c --- shujit-0.2.9a/compile.c Mon Feb 15 00:55:33 1999 +++ shujit/compile.c Tue Feb 23 20:34:07 1999 @@ -203,24 +203,21 @@ unsigned char *p; int i; - snprintf(funcname, 256, "code-%s#%s%s", + snprintf(funcname, 256, "%s_%s%s", cbName(fieldclass(&mb->fb)), mb->fb.name, mb->fb.signature); for (p = funcname; *p != '\0'; p++) { switch (*p) { case '(': case ')': - *p = '-'; break; + *p = '_'; break; case '/': case ';': case '<': case '>': *p = '_'; break; -#if 0 - case '#': *p = 'q'; break; - case '[': *p = 'a'; break; -#endif + case '[': *p = '_'; break; } } - snprintf(fname, 256, "%s.S", funcname); + snprintf(fname, 256, "code-%s.S", funcname); if (!(codefp = fopen(fname, "w"))) { perror("fopen"); goto code_open_failed; } @@ -244,6 +241,7 @@ #ifdef COMPILE_DEBUG printf("compileMethod() done.\n %s#%s %s\n", cbName(fieldclass(&mb->fb)), mb->fb.name, mb->fb.signature); + printf(" CompiledCode: 0x%08x\n", (int)mb->CompiledCode); fflush(stdout); #endif @@ -1169,12 +1167,28 @@ }\ CONST_GETMEMBER_DEBUG2;\ memcpy(bufp + constant_table[opcode][state][0], &slot, 4);\ + if (RUNTIME_DEBUGP)\ + if (JITDOP && (opcode == opc_##vop))\ + memcpy(bufp + constant_table[opcode][state][2], &slot, 4);\ + else\ + memcpy(bufp + constant_table[opcode][state][1], &slot, 4);\ CONST_GETMEMBER_DEBUG3;\ \ JITDO_CONST_GETMEMBER(vop)\ }\ break +#ifdef RUNTIME_DEBUG +# define RUNTIME_DEBUGP 1 +#else +# define RUNTIME_DEBUGP 0 +#endif +#ifdef JITDO +# define JITDOP 1 +#else +# define JITDOP 0 +#endif + CONST_GETMEMBER(getfield); CONST_GETMEMBER(putfield); @@ -1575,19 +1589,11 @@ break; case opc_checkcast: -#ifdef JITDO - CONST_NEW2(checkcast, 1); -#else CONST_NEW1(checkcast, 1); -#endif /* JITDO */ break; case opc_instanceof: -#ifdef JITDO - CONST_NEW2(instanceof, 1); -#else CONST_NEW1(instanceof, 1); -#endif /* JITDO */ break; case opc_multianewarray: @@ -1951,6 +1957,11 @@ memcpy(&funcptr, argoff, 4); #else funcptr = (unsigned char *)sysDynamicLink(funcp->name); + if (!funcptr) { + /* not reached. */ + fprintf(stderr, "WARNING: symbol `%s' was not resolved.\n", + funcp->name); + } #endif /* RESOLVE_SYMBOL_ON_CODE */ #ifdef RES_FUNC_DEBUG diff -aruN shujit-0.2.9a/compiler.c shujit/compiler.c --- shujit-0.2.9a/compiler.c Sun Feb 14 20:01:23 1999 +++ shujit/compiler.c Tue Feb 23 17:12:04 1999 @@ -21,10 +21,14 @@ $Id$ */ -#include /* for getenv(3) */ -#include /* for gdbm_open() */ +#include /* for getenv() */ +#include /* for gdbm_open(), stat() */ +#include /* for stat() */ + +#include "compiler.h" #if defined(EXC_BY_SIGNAL) || defined(GET_SIGCONTEXT) +# include # ifdef linux # include # endif @@ -35,8 +39,18 @@ # include /* for dl*() */ #endif /* CODE_DB */ -#include "monitor.h" /* for macro BINCLASS_{,UN}LOCK() */ -#include "compiler.h" +#if 0 +# include "monitor.h" /* for macro BINCLASS_{,UN}LOCK() */ +#else +typedef struct sys_mon sys_mon_t; +extern sys_mon_t *_binclass_lock; +# define BINCLASS_LOCK() sysMonitorEnter(_binclass_lock) +# define BINCLASS_UNLOCK() sysMonitorExit(_binclass_lock) +#endif + +#ifdef JITDO +# include "jni.h" +#endif /* @@ -229,25 +243,79 @@ /* initialization */ -#ifdef __FreeBSD__ - /* to get addresses of functions in lib[cm] with sysDynamicLink() */ - /* libc for __divdi3, __moddi3, printf, fflush */ - if (!sysAddDLSegment("/usr/lib/libc.so.3.1")) { - if (!sysAddDLSegment("/usr/lib/libc.so.3.0")) { - printf("FATAL: JIT compiler can't find libc.so.3.1 or 3.0.\n" - " You must edit compiler.c and re-compile" - " if you use libc on your system.\n"); - sysExit(1); - } - } - /* libm for fmod */ - if (!sysAddDLSegment("/usr/lib/libm.so.2.0")) { - printf("FATAL: JIT compiler can't find libm.so.2.0.\n" - " You must edit compiler.c and re-compile" - " if you use libc on your system.\n"); - sysExit(1); + /* sysAddDLSegment() some libraries to get addresses of functions */ + /* __divdi3, __moddi3, printf, fflush in libc */ + /* fmod in libm */ + { + char *libs_orig = getenv("JAVA_COMPILER_LIBS"); + if (!libs_orig) libs_orig = LIBS_ADDDLSEG; /* defined in compiler.h */ + + if (libs_orig) { + char *libs; + char sep, nextsep, *elem, *next; +#define NEXT {\ + char *commap, *barp;\ + elem = next; sep = nextsep;\ + commap = strchr(elem, ','); barp = strchr(elem, '|');\ + if (commap)\ + if (barp)\ + if (barp < commap) { next = barp; nextsep = '|'; }\ + else { next = commap; nextsep = ','; }\ + else { next = commap; nextsep = ','; }\ + else\ + if (barp) { next = barp; nextsep = '|'; }\ + else { next = strchr(elem, '\0'); nextsep = '\0'; }\ + *next = '\0'; next++;\ +} + +#define SKIP {\ + char *commap;\ + if (nextsep == ',') NEXT\ + else {\ + commap = strchr(next, ',');\ + if (commap) {\ + next = commap + 1; nextsep = ',';\ + NEXT\ + }\ + else sep = '\0';\ + }\ +} + + libs = strdup(libs_orig); + + next = libs; nextsep = '|'; /* initialize */ + NEXT + do { + int loaded = 0; + do { + struct stat buf; + if (!stat(elem, &buf)) { + if (sysAddDLSegment(elem)) { + loaded = 1; + break; + } + } +#ifdef COMPILE_DEBUG + else { + print("can't stat() file: %s\n", elem); fflush(stdout); + } +#endif + NEXT + } while (sep == '|'); + + if (!loaded) { + printf("FATAL: JIT compiler can't find required libraries: %s\n", + libs_orig); + sysExit(1); + } + + SKIP + } while (sep != '\0'); + + sysFree(libs); + } /* if (libs_orig) */ } -#endif + #if (defined(EXC_BY_SIGNAL) || defined(GET_SIGCONTEXT))&& defined(SEARCH_SIGCONTEXT) #ifdef linux @@ -451,6 +519,22 @@ fflush(stdout); #endif +#ifdef JITDO + /* force a loaded class to implement java.io.Serializable */ + { + ExecEnv *ee = EE(); JNIEnv *env = EE2JNIEnv(ee); + static ClassClass *clz_Serializable = NULL; + if (!clz_Serializable) { + jclass jclz_Ser = (*env)->FindClass(env, "java/io/Serializable"); + (*env)->NewGlobalRef(env, jclz_Ser); + clz_Serializable = DeRef(env, jclz_Ser); + } + + if (!cbIsInterface(cb) && (cb != classJavaLangObject)) + forceToImplement(ee, cb, clz_Serializable); + } +#endif + if (opt_cmplatload) { compileClass(cb); return; @@ -488,7 +572,7 @@ int32_t *ptr = ((int32_t *)&uc); #endif # endif /* SEARCH_SIGCONTEXT */ - sigcontext *sc = NULL; + SIGCONTEXT *sc = NULL; struct methodblock *mb; CodeInfo *codeinfo; uint32_t native_off; @@ -506,7 +590,7 @@ #ifdef SEARCH_SIGCONTEXT /* get signal context */ if (--sc_search_times < 0) { - sc = (sigcontext *)(ptr + sc_offset); + sc = (SIGCONTEXT *)(ptr + sc_offset); } else { /* must search */ #define SEARCH_WIDTH 50 @@ -539,10 +623,10 @@ printf("FATAL: cannot find struct sigcontext on stack."); sysExit(1); } - sc = (sigcontext *)ptr; + sc = (SIGCONTEXT *)ptr; } #else /* SEARCH_SIGCONTEXT*/ - sc = (sigcontext *)uc; + sc = (SIGCONTEXT *)uc; #endif /* SEARCH_SIGCONTEXT*/ #if defined(RUNTIME_DEBUG) || (defined(GET_SIGCONTEXT) && !defined(EXC_BY_SIGNAL)) printf("sigcontext: 0x%08x\n", (int)sc); fflush(stdout); @@ -623,7 +707,7 @@ /* jump to exception handler */ { register uint32_t exc_handler asm("eax"); - register sigcontext *sc_ptr asm("edi"); + register SIGCONTEXT *sc_ptr asm("edi"); exc_handler = (uint32_t)(mb->CompiledCode + codeinfo->exc_handler_nativeoff); diff -aruN shujit-0.2.9a/compiler.h shujit/compiler.h --- shujit-0.2.9a/compiler.h Mon Feb 15 01:56:21 1999 +++ shujit/compiler.h Tue Feb 23 22:32:51 1999 @@ -101,7 +101,7 @@ #define EXC_BY_SIGNAL #define GET_SIGCONTEXT #undef FAST_INVOKE /* is not fast :) */ -#define IGNORE_DISABLE +#undef IGNORE_DISABLE #ifdef RUNTIME_DEBUG #undef EXC_BY_SIGNAL @@ -111,7 +111,7 @@ * OS dependent macro definition */ -#if defined (linux) +#if defined(linux) # define EXECUTEJAVA_IN_ASM # if defined __GLIBC__ && __GLIBC__ >= 2 # undef RESOLVE_SYMBOL_ON_CODE @@ -119,14 +119,17 @@ # define RESOLVE_SYMBOL_ON_CODE # endif # define SEARCH_SIGCONTEXT -#elif defined (__FreeBSD__) +# define LIBS_ADDDLSEG NULL +#elif defined(__FreeBSD__) # undef EXECUTEJAVA_IN_ASM # undef RESOLVE_SYMBOL_ON_CODE # undef SEARCH_SIGCONTEXT +# define LIBS_ADDDLSEG "/usr/lib/aout/libc.so.3.1|/usr/lib/aout/libc.so.3.0|/usr/lib/libc.so.3.1|/usr/lib/libc.so.3.0,/usr/lib/aout/libm.so.2.0|/usr/lib/libm.so.2.0" #else # undef EXECUTEJAVA_IN_ASM # undef RESOLVE_SYMBOL_ON_CODE -# define SEARCH_SIGCONTEXT +# undef SEARCH_SIGCONTEXT +# define LIBS_ADDDLSEG NULL #endif @@ -135,9 +138,9 @@ # include /* for struct sigcontext */ # include /* for kernel version */ # if LINUX_VERSION_CODE < ((2<<16)+(1<<8)+(0)) -typedef struct sigcontext_struct sigcontext; /* 2.0.X */ +typedef struct sigcontext_struct SIGCONTEXT; /* 2.0.X */ # else -typedef struct sigcontext sigcontext; /* 2.1.X, 2.2.X */ +typedef struct sigcontext SIGCONTEXT; /* 2.1.X, 2.2.X */ # endif # define SC_ECX ecx # define SC_EDX edx @@ -147,7 +150,7 @@ # define SC_ESP esp # elif defined(__FreeBSD__) # include /* for struct sigcontext */ -typedef struct sigcontext sigcontext; +typedef struct sigcontext SIGCONTEXT; # define SC_ECX sc_ecx # define SC_EDX sc_edx # define SC_ESI sc_esi @@ -155,7 +158,7 @@ # define SC_EBP sc_ebp # define SC_ESP sc_esp # else -typedef struct sigcontext sigcontext; +typedef struct sigcontext SIGCONTEXT; # define SC_ECX ecx # define SC_EDX edx # define SC_ESI esi @@ -447,7 +450,7 @@ /* in runtime.c */ #if defined(EXC_BY_SIGNAL) || defined(GET_SIGCONTEXT) -extern void showSigcontext(sigcontext *sc); +extern void showSigcontext(SIGCONTEXT *sc); #endif /* EXC_BY_SIGNAL || GET_SIGCONTEXT */ extern int invocationHelper( #ifdef RUNTIME_DEBUG diff -aruN shujit-0.2.9a/invoker.c shujit/invoker.c --- shujit-0.2.9a/invoker.c Mon Feb 15 01:20:59 1999 +++ shujit/invoker.c Mon Feb 22 19:01:30 1999 @@ -23,10 +23,14 @@ #include /* for strcmp() */ -#include "monitor.h" /* for monitor{Enter,Exit}() */ -#include "threads.h" /* for JavaStackSize */ #include "compiler.h" +#if 0 +# include "threads.h" /* for JavaStackSize */ +#else +extern long JavaStackSize; +#endif + /* * Compile and invoke the method. @@ -201,7 +205,7 @@ /* %esp -= mb->nlocals * 4 */ #ifdef RUNTIME_DEBUG -# if 1 +# if 0 runtime_debug = 1; # else if ((!strcmp(cbName(mb->fb.clazz), "java/util/ResourceBundle")) @@ -210,8 +214,7 @@ else if ((!strcmp(cbName(mb->fb.clazz), "javax/swing/UIManager")) && (!strcmp(mb->fb.name, "maybeInitialize"))) runtime_debug = 1; - else if ((!strcmp(cbName(mb->fb.clazz), "NET/shudo/jitdo/ThreadPool$AThread")) - && (!strcmp(mb->fb.name, "run"))) + else if (!strcmp(cbName(mb->fb.clazz), "InvokeTest")) runtime_debug = 1; else if ((!strcmp(mb->fb.name, "main"))) runtime_debug = 1; diff -aruN shujit-0.2.9a/runtime.c shujit/runtime.c --- shujit-0.2.9a/runtime.c Mon Feb 15 01:51:15 1999 +++ shujit/runtime.c Sun Feb 21 18:21:59 1999 @@ -22,7 +22,15 @@ */ #include "compiler.h" -#include "monitor.h" /* for monitor{Enter,Exit}() and macro BINCLASS_*() */ + +#if 0 +# include "monitor.h" /* for monitor{Enter,Exit}() and macro BINCLASS_*() */ +#else +typedef struct sys_mon sys_mon_t; +extern sys_mon_t *_binclass_lock; +# define BINCLASS_LOCK() sysMonitorEnter(_binclass_lock) +# define BINCLASS_UNLOCK() sysMonitorExit(_binclass_lock) +#endif #ifdef JITDO #include "jitdo/NET_shudo_jitdo_Proxy_old.h" @@ -33,7 +41,7 @@ /* * show contents of structure sigcontext */ -void showSigcontext(sigcontext *sc) { +void showSigcontext(SIGCONTEXT *sc) { printf("EAX: %08x, ECX: %08x, EDX: %08x, EBX: %08x\n", #if defined(linux) sc->eax, sc->ecx, sc->edx, sc->ebx @@ -746,6 +754,7 @@ if (!obj) printf("(null)"); else { + ClassClass *cb; char *classname; if (obj_flags(obj) != T_NORMAL_OBJECT) goto show_array; classname = cbName(obj_array_classblock(obj)); @@ -755,6 +764,9 @@ printf(" len %d `", strlen); if (strlen) javaStringPrint((Hjava_lang_String *)obj); printf("'"); + } + else if (!strcmp(classname, "java/lang/Class")) { + printf(" (%s)", cbName((ClassClass *)obj)); } } break; diff -aruN shujit-0.2.9a/txt/jdk12 shujit/txt/jdk12 --- shujit-0.2.9a/txt/jdk12 Thu Jan 1 09:00:00 1970 +++ shujit/txt/jdk12 Sat Feb 20 13:14:56 1999 @@ -0,0 +1,32 @@ +JDK 1.2 での変更点 + +- JVMDI の整備による、java_monitor, java_mon() の消失。 +- monitorEnter(obj_monitor(obj)) -> sysMonitorExit(EE2SysThread(ee), obj) +- JAVA_VERSION, JAVA_MINOR_VERSION が 45, 3 -> 46, 0 に。(oobj.h) +- struct fieldblock + メンバ ID がなくなった。 +- struct methodblock + char *terse_signature が追加。 + code_length, exception_table_length 4バイト -> 2バイト。 + nexceptions, exceptions が移動。 +- struct Classjava_lang_Class + slottable が消失。 + miranda_mehods が追加。 + struct cbhash が消失。実質的に使われていなかった。 + slottbl_size が消失。 + protection_domain が追加。 + object_offsets 以降、多数追加。 +- CCF_* 変更多数。 +- struct lineno の縮小。unsigned long x 2 -> unsigned short x 2 +- struct covtable の変更多数。 +- struct localvar のサイズ変更。 +- struct CatchFrame のサイズ変更。 +- CONSTANT_POOL_ARRAY_* + LENGTH が 4 -> 6 + CLASSNAME_INDEX:4, SUPERNAME_INDEX:5 が追加。 + +- 引数の変更。 + pc2string(), FixupQuickInvocation() + + +- javac -g だけでなく javac -g -O でも LocalVariableTable が付くようになった。 diff -aruN shujit-0.2.9a/txt/jitdo shujit/txt/jitdo --- shujit-0.2.9a/txt/jitdo Sat Dec 5 09:49:26 1998 +++ shujit/txt/jitdo Mon Feb 22 22:30:46 1999 @@ -1,11 +1,7 @@ 実行時コンパイラによる Java 仮想マシンの分散オブジェクト対応 -Todo - - async. GC を禁止して挙動を見る。 - - JitdoController#instantiationVM(addr) で JitdoServer を起動する。 - - METHODBLOCK_VIRTUAL in code.c のおかしな挙動 - %edx (handle) が 0x4... ではなく 0x08.. となる - を追求。`/* debug code */' を有効にして調べる。 +Todo 99/2/22 + - さらなるテスト 議論 - 遠隔に渡される際に proxy に変化させずにコピーしてしまう条件。 @@ -80,4 +76,5 @@ RMI: rmic, HORB: horbc コマンド。 もっとも、Voyager は stub クラスを自動生成する。 - 遠隔操作の性能が高い。 - - ローカルな操作の性能は低い? + - ローカルな操作の性能は低いはず。 + 要評価。