提交 a3f3ff42 编写于 作者: L lzang

8241638: launcher time metrics always report 1 on Linux when _JAVA_LAUNCHER_DEBUG set

Reviewed-by: alanb, dholmes, phh, andrew
上级 969edab9
...@@ -163,7 +163,7 @@ define SetupLauncher ...@@ -163,7 +163,7 @@ define SetupLauncher
-DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \ -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \
-DPROGNAME='"$1"' $(DPACKAGEPATH) \ -DPROGNAME='"$1"' $(DPACKAGEPATH) \
$2, \ $2, \
CFLAGS_solaris := -KPIC -DHAVE_GETHRTIME, \ CFLAGS_solaris := -KPIC, \
LDFLAGS := $(LDFLAGS_JDKEXE) \ LDFLAGS := $(LDFLAGS_JDKEXE) \
$(ORIGIN_ARG) \ $(ORIGIN_ARG) \
$$($1_LDFLAGS), \ $$($1_LDFLAGS), \
......
...@@ -752,7 +752,7 @@ CounterGet() ...@@ -752,7 +752,7 @@ CounterGet()
{ {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000) + tv.tv_usec; return (tv.tv_sec * 1000000) + tv.tv_usec;
} }
......
...@@ -191,7 +191,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ ...@@ -191,7 +191,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
char *main_class = NULL; char *main_class = NULL;
int ret; int ret;
InvocationFunctions ifn; InvocationFunctions ifn;
jlong start, end; jlong start = 0, end = 0;
char jvmpath[MAXPATHLEN]; char jvmpath[MAXPATHLEN];
char jrepath[MAXPATHLEN]; char jrepath[MAXPATHLEN];
char jvmcfg[MAXPATHLEN]; char jvmcfg[MAXPATHLEN];
...@@ -367,7 +367,7 @@ JavaMain(void * _args) ...@@ -367,7 +367,7 @@ JavaMain(void * _args)
jmethodID mainID; jmethodID mainID;
jobjectArray mainArgs; jobjectArray mainArgs;
int ret = 0; int ret = 0;
jlong start, end; jlong start = 0, end = 0;
RegisterThread(); RegisterThread();
...@@ -1320,7 +1320,7 @@ LoadMainClass(JNIEnv *env, int mode, char *name) ...@@ -1320,7 +1320,7 @@ LoadMainClass(JNIEnv *env, int mode, char *name)
jmethodID mid; jmethodID mid;
jstring str; jstring str;
jobject result; jobject result;
jlong start, end; jlong start = 0, end = 0;
jclass cls = GetLauncherHelperClass(env); jclass cls = GetLauncherHelperClass(env);
NULL_CHECK0(cls); NULL_CHECK0(cls);
if (JLI_IsTraceLauncher()) { if (JLI_IsTraceLauncher()) {
...@@ -1336,7 +1336,7 @@ LoadMainClass(JNIEnv *env, int mode, char *name) ...@@ -1336,7 +1336,7 @@ LoadMainClass(JNIEnv *env, int mode, char *name)
env, cls, mid, USE_STDERR, mode, str)); env, cls, mid, USE_STDERR, mode, str));
if (JLI_IsTraceLauncher()) { if (JLI_IsTraceLauncher()) {
end = CounterGet(); end = CounterGet();
printf("%ld micro seconds to load main class\n", printf("%ld micro seconds to load main class\n",
(long)(jint)Counter2Micros(end-start)); (long)(jint)Counter2Micros(end-start));
printf("----%s----\n", JLDEBUG_ENV_ENTRY); printf("----%s----\n", JLDEBUG_ENV_ENTRY);
...@@ -1727,7 +1727,7 @@ ReadKnownVMs(const char *jvmCfgName, jboolean speculative) ...@@ -1727,7 +1727,7 @@ ReadKnownVMs(const char *jvmCfgName, jboolean speculative)
char line[MAXPATHLEN+20]; char line[MAXPATHLEN+20];
int cnt = 0; int cnt = 0;
int lineno = 0; int lineno = 0;
jlong start, end; jlong start = 0, end = 0;
int vmType; int vmType;
char *tmpPtr; char *tmpPtr;
char *altVMName = NULL; char *altVMName = NULL;
...@@ -1836,7 +1836,7 @@ ReadKnownVMs(const char *jvmCfgName, jboolean speculative) ...@@ -1836,7 +1836,7 @@ ReadKnownVMs(const char *jvmCfgName, jboolean speculative)
knownVMsCount = cnt; knownVMsCount = cnt;
if (JLI_IsTraceLauncher()) { if (JLI_IsTraceLauncher()) {
end = CounterGet(); end = CounterGet();
printf("%ld micro seconds to parse jvm.cfg\n", printf("%ld micro seconds to parse jvm.cfg\n",
(long)(jint)Counter2Micros(end-start)); (long)(jint)Counter2Micros(end-start));
} }
......
...@@ -1111,3 +1111,24 @@ ProcessPlatformOption(const char *arg) ...@@ -1111,3 +1111,24 @@ ProcessPlatformOption(const char *arg)
{ {
return JNI_FALSE; return JNI_FALSE;
} }
#ifndef __solaris__
/*
* Provide a CounterGet() implementation based on gettimeofday() which
* is universally available, even though it may not be 'high resolution'
* compared to platforms that provide gethrtime() (like Solaris). It is
* also subject to time-of-day changes, but alternatives may not be
* known to be available at either build time or run time.
*/
uint64_t CounterGet() {
uint64_t result = 0;
struct timeval tv;
if (gettimeofday(&tv, NULL) != -1) {
result = 1000000LL * (uint64_t)tv.tv_sec;
result += (uint64_t)tv.tv_usec;
}
return result;
}
#endif // !__solaris__
...@@ -26,17 +26,17 @@ ...@@ -26,17 +26,17 @@
#ifndef JAVA_MD_SOLINUX_H #ifndef JAVA_MD_SOLINUX_H
#define JAVA_MD_SOLINUX_H #define JAVA_MD_SOLINUX_H
#ifdef HAVE_GETHRTIME #include <sys/time.h>
#ifdef __solaris__
/* /*
* Support for doing cheap, accurate interval timing. * Support for doing cheap, accurate interval timing.
*/ */
#include <sys/time.h>
#define CounterGet() (gethrtime()/1000) #define CounterGet() (gethrtime()/1000)
#define Counter2Micros(counts) (counts) #define Counter2Micros(counts) (counts)
#else /* ! HAVE_GETHRTIME */ #else /* ! __solaris__ */
#define CounterGet() (0) uint64_t CounterGet(void);
#define Counter2Micros(counts) (1) #define Counter2Micros(counts) (counts)
#endif /* HAVE_GETHRTIME */ #endif /* __solaris__ */
/* pointer to environment */ /* pointer to environment */
extern char **environ; extern char **environ;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册