diff -aruN shujit-0.1/ChangeLog shujit/ChangeLog --- shujit-0.1/ChangeLog Sun Sep 20 21:38:35 1998 +++ shujit/ChangeLog Sat Sep 26 17:15:56 1998 @@ -1,5 +1,50 @@ $Id$ +[19980926] + +new 命令で、native code が自身を書き換える際のオフセット、 +FreeBSD の場合の値を記述。 +(code.c) + +FreeBSD で動作。 +javac, CaffeineMark 3.0 他で動作を確認。 + +0.2 リリース。 + +[19980925] + +lmul 命令 (64bit 整数の乗算) を、関数呼び出しから自前の実装に切替えた。 +FreeBSD 版 JDK では関数 (__muldi3()) を利用できないので。 +(code.c) + +[19980922] + +FreeBSD の dlsym() では、shared library を dlopen(..., RTLD_LAZY) した場合に、 +関数のアドレスはその関数が実行されるまで (?) 解決されないようなので、 +関数のアドレスを直接得ようとしているコードを +sysDynamicLink() を使うようにした。 +(compile.c) + +FreeBSD の場合、gentable.rb が constants.c 中の関数テーブルを生成する際に +関数名の頭の `_' を削除するようにした。 +(gentable.rb) + +Linux では sysDynamicLink() で libc 中のシンボルのアドレスを得られるが、 +FreeBSD では得られない。 +得られるように libc を sysAddDLSegment() しておくようにした。 +(compiler.c) + +[19980921] + +オプション (環境変数 JAVA_COMPILER_OPT で与える)、codesize を用意。 +メソッドごとの、byte code の命令数、サイズ、生成されたコードのサイズの表を +ファイル `jit_codesize' に出力する。 +(compiler.c, compile.c, compiler.h) + +コードサイズの合計、生成されたコード / byte code の比を計算する +ruby スクリプトを用意。 +(rate_codesize.rb) + [19980920] 0.1 リリース。 diff -aruN shujit-0.1/Makefile shujit/Makefile --- shujit-0.1/Makefile Sat Sep 19 20:30:08 1998 +++ shujit/Makefile Sat Sep 26 16:26:05 1998 @@ -27,7 +27,7 @@ INCDIR = -I${J_HOME}/include -I${J_HOME}/include/genunix -I${J_HOME}/include/freebsd OPTFLAGS = -O2 -CDEBUGFLAGS =# -g -DRUNTIME_DEBUG -DCOMPILE_DEBUG# -DNO_CHECK# -DOUTPUT_CODE +CDEBUGFLAGS =# -g -DRUNTIME_DEBUG -DCOMPILE_DEBUG# -DNO_CHECK CFLAGS = -pipe -fPIC ${OPTFLAGS} ${CDEBUGFLAGS} ${INCDIR} NOOPTCFLAGS = -pipe -fPIC ${CDEBUGFLAGS} ${INCDIR} diff -aruN shujit-0.1/README shujit/README --- shujit-0.1/README Sun Sep 20 21:26:25 1998 +++ shujit/README Sat Sep 26 17:22:19 1998 @@ -7,9 +7,13 @@ Working on the following platforms is confirmed. - Linux - - JDK 1.1.6v2 (ported by Steve Byrne), 1.1.5v5 + - JDK 1.1.6v2 (ported by Steve Byrne) and Linux 2.1.117 + - JDK 1.1.5v5 and Linux 2.0.35 - Not tested on 1.1.6v3a, 1.1.6v4a, but runs with that releases. +- FreeBSD + - JDK 1.1.6 (jdk1.1.6.V98-8-14.tar.gz) and FreeBSD 2.2.7R + * Installation Copy the library libshujit.so to the path in LD_LIBRARY_PATH variable @@ -55,8 +59,8 @@ This is free software which is copyrighted by Kazuyuki SHUDO. You may distrribute and modify it under the terms -of the GNU General Public License. See GPL.txt for more -details. +version 2 of the GNU General Public License. See GPL.txt +for more details. * Thanks diff -aruN shujit-0.1/code.c shujit/code.c --- shujit-0.1/code.c Sat Sep 19 19:20:07 1998 +++ shujit/code.c Sat Sep 26 15:30:25 1998 @@ -1080,7 +1080,7 @@ /* push array->body[obj_length(..)] */\ "pushl %eax\n\t" /* push value */\ /* call is_instance_of(value, array->body[eax], ee) */\ - "call is_instance_" SYMBOL(of) "@PLT\n\t"\ + "call " SYMBOL(is_instance_of) "@PLT\n\t"\ "addl $12,%esp");\ /* if (eax) goto ... */\ __asm__("testl %eax,%eax");\ @@ -1570,6 +1570,9 @@ #ifdef RUNTIME_DEBUG # define ARITH_LONG_CALL_DEBUG1(OPTOP1_REG, OPTOP2_REG, SYM) \ if (runtime_debug) {\ + __asm__("pushl %eax\n\tpushl %edi");\ + __asm__("movl 8(%esp),%eax\n\t"\ + "movl 12(%esp),%edi");\ DEBUG_IN;\ __asm__("pushl " #OPTOP2_REG "\n\t"\ "pushl " #OPTOP1_REG "\n\t"\ @@ -1579,48 +1582,68 @@ "addl $20,%esp");\ FFLUSH;\ DEBUG_OUT;\ + __asm__("popl %edi\n\tpopl %eax");\ } #else # define ARITH_LONG_CALL_DEBUG1(OPTOP1_REG, OPTOP2_REG, SYM) #endif -#define ARITH_LONG_CALL_ST24(ROP, OPTOP1_REG, OPTOP2_REG, SYM) \ - __asm__("popl %eax\n\t" /* eax = v1[0:31] */\ - "popl %edi"); /* edi = v1[32:63] */\ - ARITH_LONG_CALL_DEBUG1(OPTOP1_REG, OPTOP2_REG, SYM);\ - FUNCCALL_IN(0);\ - __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 $16,%esp");\ - __asm__(/* movl %edx,%edx */\ - "movl %eax,%ecx");\ - FUNCCALL_OUT(0) - /* now state 2 */ +#define LMUL_ST24(OPTOP1, LOW_WORD, HIGH_WORD) \ + __asm__("movl " #OPTOP1 ",%eax\n\t"\ + "movl %edx,%edi\n\t"\ + "mull (%esp)\n\t"\ + "movl %eax,-8(%esp)\n\t"\ + "movl %edx,-4(%esp)\n\t"\ + "imull 4(%esp)," #LOW_WORD "\n\t"\ + "addl " #LOW_WORD ",-4(%esp)\n\t"\ + "imull (%esp)," #HIGH_WORD "\n\t"\ + "addl " #HIGH_WORD ",-4(%esp)\n\t"\ + "movl -8(%esp),%ecx\n\t"\ + "movl -4(%esp),%edx\n\t" /* now state 2 */\ + "addl $8,%esp") CODE(opc_lmul, lmul, ST0, ST2) { __asm__("popl %ecx\n\t" "popl %edx"); /* now state 2 */ - ARITH_LONG_CALL_ST24(__muldi3, %ecx, %edx, "*"); + ARITH_LONG_CALL_DEBUG1(%ecx, %edx, "*"); + LMUL_ST24(%ecx, %ecx, %edi); } CODE(opc_lmul, lmul, ST1, ST2) { __asm__("popl %ecx"); /* now state 4 */ - ARITH_LONG_CALL_ST24(__muldi3, %edx, %ecx, "*"); + ARITH_LONG_CALL_DEBUG1(%edx, %ecx, "*"); + LMUL_ST24(%edx, %edi, %ecx); } CODE(opc_lmul, lmul, ST2, ST2) { - ARITH_LONG_CALL_ST24(__muldi3, %ecx, %edx, "*"); + ARITH_LONG_CALL_DEBUG1(%ecx, %edx, "*"); + LMUL_ST24(%ecx, %ecx, %edi); } CODE(opc_lmul, lmul, ST3, ST2) { __asm__("popl %edx"); /* now state 2 */ - ARITH_LONG_CALL_ST24(__muldi3, %ecx, %edx, "*"); + ARITH_LONG_CALL_DEBUG1(%ecx, %edx, "*"); + LMUL_ST24(%ecx, %ecx, %edi); } CODE(opc_lmul, lmul, ST4, ST2) { - ARITH_LONG_CALL_ST24(__muldi3, %edx, %ecx, "*"); + ARITH_LONG_CALL_DEBUG1(%edx, %ecx, "*"); + LMUL_ST24(%edx, %edi, %ecx); } /* ldiv, lrem */ +#define ARITH_LONG_CALL_ST24(ROP, OPTOP1_REG, OPTOP2_REG, SYM) \ + ARITH_LONG_CALL_DEBUG1(OPTOP1_REG, OPTOP2_REG, SYM);\ + __asm__("popl %eax\n\t" /* eax = v1[0:31] */\ + "popl %edi"); /* edi = v1[32:63] */\ + FUNCCALL_IN(0);\ + __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 $16,%esp");\ + __asm__(/* movl %edx,%edx */\ + "movl %eax,%ecx");\ + FUNCCALL_OUT(0) + /* now state 2 */ + #define LONG_TEST_ST24(VOP, STATE) \ /* if ((%edx == 0) && (%ecx == 0)) throw Arith.Exc.; */\ __asm__("movl %edx,%eax\n\t"\ @@ -1656,8 +1679,8 @@ ARITH_LONG_CALL_ST24(ROP, %edx, %ecx, SYM);\ } - CODE_ARITH_LONG_TEST(div, __divdi3, "/"); - CODE_ARITH_LONG_TEST(rem, __moddi3, "mod"); + CODE_ARITH_LONG_TEST(div, SYMBOL(__divdi3), "/"); + CODE_ARITH_LONG_TEST(rem, SYMBOL(__moddi3), "mod"); /* fadd, fsub, fmul, fdiv */ #ifdef RUNTIME_DEBUG @@ -3489,11 +3512,20 @@ # define NEW_DEBUG2(OBJ_REG) #endif -#ifdef RUNTIME_DEBUG -# define NEW_REWRITE_OFFSET_0 0x35 -#else -# define NEW_REWRITE_OFFSET_0 5 +#if defined(linux) +# ifdef RUNTIME_DEBUG +# define NEW_REWRITE_OFFSET_0 0x35 +# else +# define NEW_REWRITE_OFFSET_0 5 +# endif +#elif defined(__FreeBSD__) +# ifdef RUNTIME_DEBUG +# define NEW_REWRITE_OFFSET_0 0x3a +# else +# define NEW_REWRITE_OFFSET_0 5 +# endif #endif + # define NEW_REWRITE_OFFSET_1 NEW_REWRITE_OFFSET_0 # define NEW_REWRITE_OFFSET_2 (NEW_REWRITE_OFFSET_0 + 1) # define NEW_REWRITE_OFFSET_3 NEW_REWRITE_OFFSET_0 @@ -3739,7 +3771,7 @@ __asm__("pushl %0" : : "m" (ee)); /* ee */\ __asm__("pushl $" STR(CONST) "\n\t" /* cb */\ "pushl " #OPTOP1_REG "\n\t"\ - "call is_instance_" SYMBOL(of) "@PLT\n\t"\ + "call " SYMBOL(is_instance_of) "@PLT\n\t"\ "addl $12,%esp");\ FUNCCALL_OUT(STATE);\ __asm__("testl %eax,%eax\n\t"\ @@ -3773,7 +3805,7 @@ __asm__("pushl %0" : : "m" (ee)); /* ee */\ __asm__("pushl $" STR(CONST) "\n\t"\ "pushl " #OPTOP1_REG "\n\t"\ - "call is_instance_" SYMBOL(of) "@PLT\n\t"\ + "call " SYMBOL(is_instance_of) "@PLT\n\t"\ "addl $12,%esp");\ FUNCCALL_OUT(STATE);\ __asm__("movl %eax," #OPTOP1_REG "\n\t"\ diff -aruN shujit-0.1/code.h shujit/code.h --- shujit-0.1/code.h Sat Sep 19 19:22:28 1998 +++ shujit/code.h Tue Sep 22 20:00:40 1998 @@ -79,45 +79,6 @@ /* - * code header - * for each opcode of JVM. - * - * 0x0f, 0x0f, - * 0xe9, opcode(2 byte), initial state(1 byte), last state(1 byte) - */ - -#ifdef RUNTIME_DEBUG -# define CODE_DEBUG(LABEL) \ - if (runtime_debug) {\ - __asm__("pushl %eax\n\t"\ - "movl %esp,%eax\n\t"\ - "addl $4,%eax");\ - DEBUG_IN;\ - __asm__("pushl %eax"); /* %esp */\ - __asm__("pushl %0" : : "m" (ee));\ - PUSH_CONSTSTR(">" LABEL " %x %x\n");\ - __asm__("call " SYMBOL(printf) "@PLT\n\t"\ - "addl $12,%esp");\ - FFLUSH;\ - DEBUG_OUT;\ - __asm__("popl %eax");\ - } -#else -# define CODE_DEBUG(LABEL) -#endif - -#define CODE(OPCODE, LABEL, STATE, NEXTST) \ - _CODE(OPCODE, LABEL, STATE, NEXTST); -#define _CODE(OPCODE, LABEL, STATE, NEXTST) \ - __asm__(\ - ".byte 0x0f,0x0f\n\t"\ - ".byte 0xe9," #OPCODE ",0," #STATE "," #NEXTST);\ - CODE_DEBUG(#LABEL "(" #STATE "->" #NEXTST ")") - -#define CODEEND __asm__(".byte 0x0f,0x0f,0x0f,0x0f") - - -/* * utilities */ @@ -201,6 +162,45 @@ #else # define NULL_TEST(REG, LABEL) #endif + + +/* + * code header + * for each opcode of JVM. + * + * 0x0f, 0x0f, + * 0xe9, opcode(2 byte), initial state(1 byte), last state(1 byte) + */ + +#ifdef RUNTIME_DEBUG +# define CODE_DEBUG(LABEL) \ + if (runtime_debug) {\ + __asm__("pushl %eax\n\t"\ + "movl %esp,%eax\n\t"\ + "addl $4,%eax");\ + DEBUG_IN;\ + __asm__("pushl %eax"); /* %esp */\ + __asm__("pushl %0" : : "m" (ee));\ + PUSH_CONSTSTR(">" LABEL " %x %x\n");\ + __asm__("call " SYMBOL(printf) "@PLT\n\t"\ + "addl $12,%esp");\ + FFLUSH;\ + DEBUG_OUT;\ + __asm__("popl %eax");\ + } +#else +# define CODE_DEBUG(LABEL) +#endif + +#define CODE(OPCODE, LABEL, STATE, NEXTST) \ + _CODE(OPCODE, LABEL, STATE, NEXTST); +#define _CODE(OPCODE, LABEL, STATE, NEXTST) \ + __asm__(\ + ".byte 0x0f,0x0f\n\t"\ + ".byte 0xe9," #OPCODE ",0," #STATE "," #NEXTST);\ + CODE_DEBUG(#LABEL "(" #STATE "->" #NEXTST ")") + +#define CODEEND __asm__(".byte 0x0f,0x0f,0x0f,0x0f") /* diff -aruN shujit-0.1/codesize shujit/codesize --- shujit-0.1/codesize Thu Jan 1 09:00:00 1970 +++ shujit/codesize Mon Sep 21 22:13:53 1998 @@ -0,0 +1,44 @@ +生成コードのサイズ + +methodhead (eb, 235) + 1f (31) +exception_handler (ec, 236) + 29 (41) +methodtail (ed, 237) + 9 (9) + +1. 次のクラスでテスト + class DoNothing { + public static void main(String[] argv) { + } + } + +* javac + +% javac -g -O DoNothing.java + +num of byte code inst: 29599 +byte code size (byte): 59544 +native code size (byte): 1069178 +native code size / num of inst: 36.1221 +native code size / byte code size: 17.9561 + +* 実行 + +% java DoNothing + +num of byte code inst: 346 +byte code size (byte): 590 +native code size (byte): 12053 +native code size / num of inst: 34.8353 +native code size / byte code size: 20.4288 + +2. E2 暗号化 + +% java EvalLargeData + +num of byte code inst: 9899 +byte code size (byte): 13133 +native code size (byte): 191170 +native code size / num of inst: 19.3121 +native code size / byte code size: 14.5565 diff -aruN shujit-0.1/compile.c shujit/compile.c --- shujit-0.1/compile.c Sat Sep 12 01:35:56 1998 +++ shujit/compile.c Fri Sep 25 15:10:43 1998 @@ -122,11 +122,51 @@ resolveFunctionSymbols(cc); - freeCompilerContext(cc); - mb->fb.access |= ACC_MACHINE_COMPILED; - mb->invoker = invokeCompiledMethod; /* in invoker.c */ + mb->invoker = +#ifdef CAN_REF_SYM_BEFORE_EXEC + invokeCompiledMethod; +#else + (bool_t (*)(JHandle *, struct methodblock *, int, struct execenv *)) + sysDynamicLink("invokeCompiledMethod"); +#endif + /* invokeCompiledMethod() is in invoker.c */ + + /* write code size */ + + if (opt_codesize) { + static FILE *sizefp = NULL; + + if (!sizefp) { + if (!(sizefp = fopen(CODESIZE_FNAME, "w"))) { + perror("fopen"); + opt_codesize = 0; + goto codesize_open_failed; + } + + fprintf(sizefp, "# num_of_byte_code_inst" + " size_of_byte_code" + " size_of_native_code" + " class_name#method_name signature\n"); + } + + fprintf(sizefp, "%d", cc->pctablelen - 3); + /* # of byte code inst */ + /* 3 are method{head,tail}, exc. handler. */ + fprintf(sizefp, "\t%lu", mb->code_length); + /* size of byte code of the method */ + fprintf(sizefp, "\t%d", info->code_size); + /* size of generated native code */ + fprintf(sizefp, "\t%s#%s %s", + cbName(fieldclass(&mb->fb)), mb->fb.name, mb->fb.signature); + /* class name, method name, signature */ + fprintf(sizefp, "\n"); + } +codesize_open_failed: + + + freeCompilerContext(cc); /* write generated code to the file code_.c */ @@ -153,7 +193,7 @@ snprintf(fname, 256, "%s.S", funcname); if (!(codefp = fopen(fname, "w"))) { - perror("fopen"); goto open_failed; + perror("fopen"); goto code_open_failed; } fprintf(codefp, ".globl %s\n", funcname); @@ -167,7 +207,7 @@ fclose(codefp); } -open_failed: +code_open_failed: #ifdef COMPILE_DEBUG @@ -1587,7 +1627,6 @@ #endif RESOLVE_SYMBOL_ON_CODE -#undef RESOLVE_FUNC_DEBUG static void resolveFunctionSymbols(CompilerContext *cc) { unsigned char *nativeCode = cc->mb->CompiledCode; @@ -1595,7 +1634,7 @@ pcentry *pctable_end = pctable + cc->pctablelen; FuncTable *funcp; -#ifdef RESOLVE_FUNC_DEBUG +#ifdef COMPILE_DEBUG printf("resolveFuncSym() called.\n"); fflush(stdout); #endif @@ -1617,7 +1656,7 @@ funcptr = (unsigned char *)sysDynamicLink(funcp->name); #endif -#ifdef RESOLVE_FUNC_DEBUG +#ifdef COMPILE_DEBUG printf(" symbol `%s': 0x%08x at 0x%x(%d) + %d\n", funcp->name, (int)funcptr, pctable->nativeoff, pctable->nativeoff, funcp->offset); @@ -1631,7 +1670,7 @@ pctable++; } -#ifdef RESOLVE_FUNC_DEBUG +#ifdef COMPILE_DEBUG printf("resolveFuncSym() done.\n"); fflush(stdout); #endif } diff -aruN shujit-0.1/compiler.c shujit/compiler.c --- shujit-0.1/compiler.c Sat Sep 12 01:09:53 1998 +++ shujit/compiler.c Sat Sep 26 16:17:01 1998 @@ -22,6 +22,7 @@ int opt_quiet = 0; int opt_outcode = 0; +int opt_codesize = 0; /* @@ -76,6 +77,8 @@ opt_quiet = 1; else if (!strncmp(opt, "outcode", 8)) opt_outcode = 1; + else if (!strncmp(opt, "codesize", 9)) + opt_codesize = 1; opt = strtok(NULL, ", "); } } @@ -109,6 +112,18 @@ /* initialization */ +#ifdef __FreeBSD__ + /* to get addresses of functions in libc with sysDynamicLink() */ + if (!sysAddDLSegment("/usr/lib/libc.so.3.1")) { + if (!sysAddDLSegment("/usr/lib/libc.so.3.0")) { + printf(" shuJIT can't find libc.so.3.1 or 3.0 on this system.\n" + " You must edit compiler.c and re-compile" + " if you use libc on your system.\n"); + sysExit(1); + } + } +#endif + #ifdef RESOLVE_SYMBOL_ON_CODE initFunctionSymbols(); #endif @@ -145,6 +160,7 @@ *(char **)vector[10] = (char *)pcInCompiledCode; *(char **)vector[11] = (char *)compiledCodePC; *(char **)vector[70] = (char *)framePrev; + #ifdef COMPILE_DEBUG printf("java_lang_Compiler_start() done.\n"); diff -aruN shujit-0.1/compiler.h shujit/compiler.h --- shujit-0.1/compiler.h Sat Sep 19 19:43:49 1998 +++ shujit/compiler.h Sat Sep 26 17:27:09 1998 @@ -77,6 +77,21 @@ /* + * OS dependent macro definition + */ +#if defined (linux) +# define EXECUTEJAVA_IN_ASM +# define CAN_REF_SYM_BEFORE_EXEC +#elif defined (__FreeBSD__) +# undef EXECUTEJAVA_IN_ASM +# undef CAN_REF_SYM_BEFORE_EXEC +#else +# undef EXECUTEJAVA_IN_ASM +# undef CAN_REF_SYM_BEFORE_EXEC +#endif + + +/* * Select appropriate malloc library */ # define sysMalloc malloc @@ -89,10 +104,12 @@ * Macros */ -#define CREDIT " shuJIT for x86/JDK Copyright (c) 1998 SHUDO Kazuyuki\n" +#define CREDIT " shuJIT for Sun JVM/IA32 Copyright (c) 1998 SHUDO Kazuyuki\n" #define COMPILER_VERSION 5 +#define CODESIZE_FNAME "jit_codesize" + #ifndef MIN # define MIN(a,b) ((a)<(b)?(a):(b)) #endif @@ -165,6 +182,7 @@ extern int opt_quiet; extern int opt_outcode; +extern int opt_codesize; /* diff -aruN shujit-0.1/gentable.rb shujit/gentable.rb --- shujit-0.1/gentable.rb Sun Aug 23 22:06:37 1998 +++ shujit/gentable.rb Sat Sep 26 15:36:21 1998 @@ -167,6 +167,11 @@ chomp!() elems = split() funcname = elems.pop() + # _funcname -> funcname + if funcname =~ /^_/ && PLATFORM =~ /-freebsd/ + # in the case of FreeBSD + funcname = funcname[1...funcname.length()] + end #print "function offset: #{off}, name: #{funcname}\n" if init_state == STANY array = func_table[opcode][0] diff -aruN shujit-0.1/invoker.c shujit/invoker.c --- shujit-0.1/invoker.c Wed Aug 19 17:51:22 1998 +++ shujit/invoker.c Fri Sep 25 15:13:27 1998 @@ -83,11 +83,11 @@ # if 1 runtime_debug = 1; # else - if ((!strcmp(cbName(mb->fb.clazz), "java/lang/FloatingDecimal")) - && (!strcmp(mb->fb.name, "toJavaFormatString"))) + if ((!strcmp(cbName(mb->fb.clazz), "sun/tools/java/Scanner")) + && (!strcmp(mb->fb.name, "scanNumber"))) runtime_debug = 1; - else if ((!strcmp(cbName(mb->fb.clazz), "java/util/Hashtable")) - && (!strcmp(mb->fb.name, "put"))) + else if ((!strcmp(cbName(mb->fb.clazz), "java/lang/FloatingDecimal")) + && (!strcmp(mb->fb.name, "toJavaFormatString"))) runtime_debug = 1; else if ((!strcmp(cbName(mb->fb.clazz), "E2.E2_Algorithm")) && (!strcmp(mb->fb.name, "blockEncrypt"))) diff -aruN shujit-0.1/memo shujit/memo --- shujit-0.1/memo Sat Sep 19 15:24:18 1998 +++ shujit/memo Sat Sep 26 15:51:15 1998 @@ -29,8 +29,6 @@ Todo - FreeBSD, Win32 に移植。 - - compiled code のサイズの表を作成、表示 - CODESIZE_DEBUG - よりハードなテスト。 MC のコンパイルなど。 - credit を考える。 @@ -53,6 +51,8 @@ javac の、フックをかけられる箇所を探す。 Done + - compiled code のサイズの表を作成、表示 + CODESIZE_DEBUG - invokeignored_quick で pc[2] == 0 の場合、null check コードを省く。 - x86 の CMOVcc (および FCMOVcc) の適用を検討する。 w/ MMX でない Pentium 以前は {,F}CMOVcc を持たない。 @@ -63,6 +63,16 @@ コンパイルできるようにする。 - ジャンプ前の state からジャンプ後の state へ移行コードが必要。 tableswitch, lookupswitch はトランポリン方式で解決。 + +移植時の注意 + - Linux のように、dlopen(..., RTLD_LAZY) なライブラリ中の + 関数のアドレスを関数実行前に得られるか、FreeBSD のように得られないか。 + - Linux の JDK のように、libc 中の関数のアドレスを sysDynamicLink() で + 得られるか、FreeBSD の JDK のように得られないか。 + - 関数名シンボルが funcname か _funcname か。 + gentable.rb の挙動を変える。 + - JVM の new 命令の self modify 時の offset + 例: Linux では 0x35, FreeBSD では 0x3a 注記 - code.c の NEW_REWRITE_OFFSET_# は、code.h のマクロ CODE() の定義に diff -aruN shujit-0.1/rate_codesize.rb shujit/rate_codesize.rb --- shujit-0.1/rate_codesize.rb Thu Jan 1 09:00:00 1970 +++ shujit/rate_codesize.rb Mon Sep 21 20:50:09 1998 @@ -0,0 +1,31 @@ +#!/usr/local/bin/ruby +# +# calculate the ratio: +# size of generated native code/ +# {size of byte code, number of byte code instructions} +# +# 1. Set JAVA_COMPILER_OPT codesize +# 2. You'll get the file `jit_codesize' running Java program with JIT compiler. +# 3. % rate_codesize.rb jit_codesize + +DEFAULT_FNAME = 'jit_codesize' + +ninst = 0 +byte_size = 0 +native_size = 0 + +while gets() + next if /^#/ + chomp!() + elems = split() + ninst += elems[0].to_i() + byte_size += elems[1].to_i() + native_size += elems[2].to_i() +end + +print "num of byte code inst: #{ninst}\n" +print "byte code size (byte): #{byte_size}\n" +print "native code size (byte): #{native_size}\n" + +print "native code size / num of inst: #{native_size.to_f() / ninst}\n" +print "native code size / byte code size: #{native_size.to_f() / byte_size}\n" diff -aruN shujit-0.1/runtime.c shujit/runtime.c --- shujit-0.1/runtime.c Sun Sep 6 14:17:25 1998 +++ shujit/runtime.c Fri Sep 25 17:55:25 1998 @@ -86,8 +86,11 @@ /* restack from native stack to JVM stack */ stackpointer += (narg - 1); - if ((method->invoker == invokeCompiledMethod) || - (method->invoker == compileAndInvokeMethod)) { + if (method->fb.access & ACC_MACHINE_COMPILED) { + /* is expected to be equal to: + ((method->invoker == invokeCompiledMethod) || + (method->invoker == compileAndInvokeMethod)) + */ /* compiled method */ ee->current_frame->returnpc = (unsigned char *)stackpointer; } @@ -173,7 +176,7 @@ exec_ret = ExecuteJava(method->code, ee); cur_frame = ee->current_frame; old_optop = cur_frame->optop; -#ifndef EXECUTEJAVA_IN_C +#ifdef EXECUTEJAVA_IN_ASM if (cur_frame->monitor) monitorExit(obj_monitor(obj)); #endif @@ -181,7 +184,7 @@ ee->current_frame = cur_frame; if (!exec_ret) return -1; -#ifndef EXECUTEJAVA_IN_C +#ifdef EXECUTEJAVA_IN_ASM /* These operation is required with only x86 assembly ver. of executeJava.c */ optop = cur_frame->optop; @@ -192,8 +195,8 @@ optop[0] = old_optop[-2]; optop[1] = old_optop[-1]; optop += 2; } cur_frame->optop = optop; - } #endif + } #ifdef RUNTIME_DEBUG if (runtime_debug) {