From owner-freebsd-java Mon Jul 24 15:12:30 2000 Delivered-To: freebsd-java@freebsd.org Received: from tkh.att.ne.jp (tkh.att.ne.jp [165.76.17.8]) by hub.freebsd.org (Postfix) with ESMTP id 6FBFC37BE4A for ; Mon, 24 Jul 2000 15:12:12 -0700 (PDT) (envelope-from fuyuhik8@is.titech.ac.jp) Received: from tripper.is.titech.ac.jp.is.titech.ac.jp (176.pool27.tokyo.att.ne.jp [165.76.232.191]) by tkh.att.ne.jp (8.8.8+Spin/3.6W-CONS(07/05/00)) id HAA19690; Tue, 25 Jul 2000 07:12:07 +0900 (JST) Date: Tue, 25 Jul 2000 07:14:50 +0900 Message-ID: <55ittv41lx.wl@is.titech.ac.jp> From: Fuyuhiko Maruyama To: freebsd-java@FreeBSD.ORG Subject: Patches to allow timing based profiling. User-Agent: Wanderlust/2.2.18 (Please Forgive Me) on XEmacs/21.2.35 "Nike" MIME-Version: 1.0 (generated by SEMI 1.13.7 - "Awazu") Content-Type: multipart/mixed; boundary="Multipart_Tue_Jul_25_07:14:43_2000-1" Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --Multipart_Tue_Jul_25_07:14:43_2000-1 Content-Type: text/plain; charset=US-ASCII Hi, all. I made a patches to allow timing based profiling (using hprof) on FreeBSD JDK 1.2.2 (with patchset-9). Patches attached this mail make two contributions: 1. On pentium-platform (not PentiumPro, PentiumII, K6...), there was problem JVM causes Segmentation Fault when profiling is enabled. This is assembler version interpretter's bug (may be in Solaris/Win32 version). The patch for executeJava_p5.inc fix this bug. 2. Patchset-9 doesn't give meaningful value for sysThreadCPUTime() function. On Solaris, the function is implemented using gethrvtime() which doesn't exist on FreeBSD, so patchset-9 used to simply return 0. This is not so serious problem whenever timing based profiling isn't used. The patch for threads_md.c implement the function using getrusage(...). This may be too heavy function, but I don't know any other simple alternatives. The good news is, it will be used *only when* timing based profiling is enabled, so I believe the heavyness of sysThreadCPUTime() doesn't affect the efficiency of non-profiling run. With this patches, you can get timing based profiling data using hprof like: $ java -Xrunhprof:cpu=times Hello Thank you. -- Fuyuhiko Maruyama Matsuoka laboratory, Department of Mathematical and Computing Sciences, Graduate School of Tokyo Institute of Technology. --Multipart_Tue_Jul_25_07:14:43_2000-1 Content-Type: application/octet-stream Content-Disposition: attachment; filename="profiling.diffs" Content-Transfer-Encoding: 7bit --- src/share/javavm/runtime/executeJava_p5.inc.orig Tue Jun 29 19:16:43 1999 +++ src/share/javavm/runtime/executeJava_p5.inc Mon Jul 24 12:15:57 2000 @@ -220,6 +220,7 @@ jnz Lb(Profiling_jvmpi_$1) Lb(BackFromProfiling_jvmpi_$1): + xor eax, eax MOV(eax, al, BYTE PTR [esi]) Dispatch0 --- src/freebsd/hpi/green_threads/src/threads_md.c.orig Tue Jun 20 03:01:46 2000 +++ src/freebsd/hpi/green_threads/src/threads_md.c Mon Jul 3 11:41:38 2000 @@ -20,7 +20,9 @@ #include #ifdef __FreeBSD__ +#include #include +#include #else #include #endif @@ -953,12 +955,27 @@ static jlong sliceStartTime = -1; +#ifdef __FreeBSD__ +static inline jlong +ruGethrvtime() +{ + struct rusage rusage; + jlong time; + getrusage(RUSAGE_SELF, &rusage); + return ((jlong)rusage.ru_utime.tv_sec) * (jlong)1000000000 + + ((jlong)rusage.ru_utime.tv_usec * (jlong)1000) + + ((jlong)rusage.ru_stime.tv_sec) * (jlong)1000000000 + + ((jlong)rusage.ru_stime.tv_usec * (jlong)1000); +} +#endif + jlong sysThreadCPUTime() { sys_thread_t * t = greenThreadSelf(); #ifdef __FreeBSD__ - jlong time = 0LL; + /* jlong time = 0LL; */ + jlong time = ruGethrvtime(); #else jlong time = gethrvtime(); #endif @@ -973,7 +990,8 @@ { sys_thread_t * t = greenThreadSelf(); #ifdef __FreeBSD__ - jlong time = 0LL; + /* jlong time = 0LL; */ + jlong time = ruGethrvtime(); #else jlong time = gethrvtime(); #endif --Multipart_Tue_Jul_25_07:14:43_2000-1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message