8245600: Clean up libjli
Reviewed-by: dholmes, alanb
This commit is contained in:
parent
6aa15ad7ab
commit
44a0a08991
@ -168,7 +168,7 @@ TARGETS += $(BUILD_LIBJIMAGE)
|
||||
##########################################################################################
|
||||
|
||||
ifeq ($(call isTargetOs, macosx), true)
|
||||
LIBJLI_EXCLUDE_FILES += java_md_solinux.c
|
||||
LIBJLI_EXCLUDE_FILES += java_md.c
|
||||
endif
|
||||
|
||||
ifeq ($(call isTargetOs, windows), true)
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#ifndef JAVA_MD_MACOSX_H
|
||||
#define JAVA_MD_MACOSX_H
|
||||
|
||||
/* CounterGet() is implemented in java_md.c */
|
||||
int64_t CounterGet(void);
|
||||
#define Counter2Micros(counts) (counts)
|
||||
|
||||
/* pointer to environment */
|
||||
#include <crt_externs.h>
|
||||
#define environ (*_NSGetEnviron())
|
||||
|
||||
/*
|
||||
* A collection of useful strings. One should think of these as #define
|
||||
* entries, but actual strings can be more efficient (with many compilers).
|
||||
*/
|
||||
static const char *user_dir = "/java";
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#endif /* JAVA_MD_MACOSX_H */
|
@ -633,18 +633,6 @@ SetExecname(char **argv)
|
||||
return exec_path;
|
||||
}
|
||||
|
||||
/*
|
||||
* BSD's implementation of CounterGet()
|
||||
*/
|
||||
int64_t
|
||||
CounterGet()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
}
|
||||
|
||||
|
||||
/* --- Splash Screen shared library support --- */
|
||||
|
||||
static JavaVM* SetJavaVMValue()
|
||||
|
@ -292,7 +292,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */
|
||||
ifn.GetDefaultJavaVMInitArgs = 0;
|
||||
|
||||
if (JLI_IsTraceLauncher()) {
|
||||
start = CounterGet();
|
||||
start = CurrentTimeMicros();
|
||||
}
|
||||
|
||||
if (!LoadJavaVM(jvmpath, &ifn)) {
|
||||
@ -300,11 +300,10 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */
|
||||
}
|
||||
|
||||
if (JLI_IsTraceLauncher()) {
|
||||
end = CounterGet();
|
||||
end = CurrentTimeMicros();
|
||||
}
|
||||
|
||||
JLI_TraceLauncher("%ld micro seconds to LoadJavaVM\n",
|
||||
(long)(jint)Counter2Micros(end-start));
|
||||
JLI_TraceLauncher("%ld micro seconds to LoadJavaVM\n", (long)(end-start));
|
||||
|
||||
++argv;
|
||||
--argc;
|
||||
@ -413,7 +412,7 @@ JavaMain(void* _args)
|
||||
RegisterThread();
|
||||
|
||||
/* Initialize the virtual machine */
|
||||
start = CounterGet();
|
||||
start = CurrentTimeMicros();
|
||||
if (!InitializeJVM(&vm, &env, &ifn)) {
|
||||
JLI_ReportErrorMessage(JVM_ERROR1);
|
||||
exit(1);
|
||||
@ -467,9 +466,8 @@ JavaMain(void* _args)
|
||||
FreeKnownVMs(); /* after last possible PrintUsage */
|
||||
|
||||
if (JLI_IsTraceLauncher()) {
|
||||
end = CounterGet();
|
||||
JLI_TraceLauncher("%ld micro seconds to InitializeJVM\n",
|
||||
(long)(jint)Counter2Micros(end-start));
|
||||
end = CurrentTimeMicros();
|
||||
JLI_TraceLauncher("%ld micro seconds to InitializeJVM\n", (long)(end-start));
|
||||
}
|
||||
|
||||
/* At this stage, argc/argv have the application's arguments */
|
||||
@ -1622,7 +1620,7 @@ LoadMainClass(JNIEnv *env, int mode, char *name)
|
||||
jclass cls = GetLauncherHelperClass(env);
|
||||
NULL_CHECK0(cls);
|
||||
if (JLI_IsTraceLauncher()) {
|
||||
start = CounterGet();
|
||||
start = CurrentTimeMicros();
|
||||
}
|
||||
NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
|
||||
"checkAndLoadMain",
|
||||
@ -1633,9 +1631,8 @@ LoadMainClass(JNIEnv *env, int mode, char *name)
|
||||
USE_STDERR, mode, str));
|
||||
|
||||
if (JLI_IsTraceLauncher()) {
|
||||
end = CounterGet();
|
||||
printf("%ld micro seconds to load main class\n",
|
||||
(long)(jint)Counter2Micros(end-start));
|
||||
end = CurrentTimeMicros();
|
||||
printf("%ld micro seconds to load main class\n", (long)(end-start));
|
||||
printf("----%s----\n", JLDEBUG_ENV_ENTRY);
|
||||
}
|
||||
|
||||
@ -2087,7 +2084,7 @@ ReadKnownVMs(const char *jvmCfgName, jboolean speculative)
|
||||
char *serverClassVMName = NULL;
|
||||
static char *whiteSpace = " \t";
|
||||
if (JLI_IsTraceLauncher()) {
|
||||
start = CounterGet();
|
||||
start = CurrentTimeMicros();
|
||||
}
|
||||
|
||||
jvmCfg = fopen(jvmCfgName, "r");
|
||||
@ -2172,9 +2169,8 @@ ReadKnownVMs(const char *jvmCfgName, jboolean speculative)
|
||||
knownVMsCount = cnt;
|
||||
|
||||
if (JLI_IsTraceLauncher()) {
|
||||
end = CounterGet();
|
||||
printf("%ld micro seconds to parse jvm.cfg\n",
|
||||
(long)(jint)Counter2Micros(end-start));
|
||||
end = CurrentTimeMicros();
|
||||
printf("%ld micro seconds to parse jvm.cfg\n", (long)(end-start));
|
||||
}
|
||||
|
||||
return cnt;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -170,6 +170,7 @@ jint ReadKnownVMs(const char *jvmcfg, jboolean speculative);
|
||||
char *CheckJvmType(int *argc, char ***argv, jboolean speculative);
|
||||
void AddOption(char *str, void *info);
|
||||
jboolean IsWhiteSpaceOption(const char* name);
|
||||
jlong CurrentTimeMicros();
|
||||
|
||||
// Utility function defined in args.c
|
||||
int isTerminalOpt(char *arg);
|
||||
|
@ -709,20 +709,3 @@ ProcessPlatformOption(const char *arg)
|
||||
{
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
@ -32,6 +32,8 @@
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include "manifest_info.h"
|
||||
#include "jli_util.h"
|
||||
|
||||
@ -61,9 +63,11 @@ static jboolean GetJREPath(char *path, jint pathsize, jboolean speculative);
|
||||
#include "java_md_aix.h"
|
||||
#endif
|
||||
|
||||
#ifdef MACOSX
|
||||
#include "java_md_macosx.h"
|
||||
#else /* !MACOSX */
|
||||
#include "java_md_solinux.h"
|
||||
#endif /* MACOSX */
|
||||
#if defined(MACOSX)
|
||||
#include <crt_externs.h>
|
||||
#define environ (*_NSGetEnviron())
|
||||
#else
|
||||
extern char **environ;
|
||||
#endif
|
||||
|
||||
#endif /* JAVA_MD_H */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,6 +22,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <sys/time.h>
|
||||
#include "java.h"
|
||||
|
||||
/*
|
||||
@ -364,3 +365,20 @@ CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
|
||||
{
|
||||
return NewPlatformStringArray(env, strv, argc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Provide a CurrentTimeMicros() 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.
|
||||
*/
|
||||
jlong CurrentTimeMicros() {
|
||||
jlong result = 0;
|
||||
struct timeval tv;
|
||||
if (gettimeofday(&tv, NULL) != -1) {
|
||||
result = 1000000LL * (jlong)tv.tv_sec;
|
||||
result += (jlong)tv.tv_usec;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#ifndef JAVA_MD_SOLINUX_H
|
||||
#define JAVA_MD_SOLINUX_H
|
||||
|
||||
#include <sys/time.h>
|
||||
uint64_t CounterGet(void);
|
||||
#define Counter2Micros(counts) (counts)
|
||||
|
||||
/* pointer to environment */
|
||||
extern char **environ;
|
||||
|
||||
/*
|
||||
* A collection of useful strings. One should think of these as #define
|
||||
* entries, but actual strings can be more efficient (with many compilers).
|
||||
*/
|
||||
static const char *user_dir = "/java";
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#endif /* JAVA_MD_SOLINUX_H */
|
@ -459,7 +459,7 @@ static jboolean counterAvailable = JNI_FALSE;
|
||||
static jboolean counterInitialized = JNI_FALSE;
|
||||
static LARGE_INTEGER counterFrequency;
|
||||
|
||||
jlong CounterGet()
|
||||
jlong CurrentTimeMicros()
|
||||
{
|
||||
LARGE_INTEGER count;
|
||||
|
||||
@ -471,16 +471,10 @@ jlong CounterGet()
|
||||
return 0;
|
||||
}
|
||||
QueryPerformanceCounter(&count);
|
||||
return (jlong)(count.QuadPart);
|
||||
|
||||
return (jlong)(count.QuadPart * 1000 * 1000 / counterFrequency.QuadPart);
|
||||
}
|
||||
|
||||
jlong Counter2Micros(jlong counts)
|
||||
{
|
||||
if (!counterAvailable || !counterInitialized) {
|
||||
return 0;
|
||||
}
|
||||
return (counts * 1000 * 1000)/counterFrequency.QuadPart;
|
||||
}
|
||||
/*
|
||||
* windows snprintf does not guarantee a null terminator in the buffer,
|
||||
* if the computed size is equal to or greater than the buffer size,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -41,13 +41,6 @@
|
||||
|
||||
#define JLONG_FORMAT_SPECIFIER "%I64d"
|
||||
|
||||
/*
|
||||
* Support for doing cheap, accurate interval timing.
|
||||
*/
|
||||
extern jlong CounterGet(void);
|
||||
extern jlong Counter2Micros(jlong counts);
|
||||
|
||||
|
||||
/*
|
||||
* Function prototypes.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user