Skip to content

Commit

Permalink
Merge pull request #3858 from hangshao0/master
Browse files Browse the repository at this point in the history
Enable class sharing by default on all openj9 builds except OSX
  • Loading branch information
pshipton authored Dec 6, 2018
2 parents bc8d933 + 7a8a339 commit d364857
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 73 deletions.
8 changes: 4 additions & 4 deletions runtime/oti/j9.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ static const struct { \
#define J9_IS_J9CLASS_VALUETYPE(clazz) FALSE
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */

#if defined(OSX)
#if defined(OPENJ9_BUILD) && !defined(OSX)
#define J9_SHARED_CACHE_DEFAULT_BOOT_SHARING(vm) TRUE
#else /* defined(OPENJ9_BUILD) && !defined(OSX) */
/* Temporarily disable default class sharing on OSX due to https://github.com/eclipse/openj9/issues/3333 */
#define J9_SHARED_CACHE_DEFAULT_BOOT_SHARING(vm) FALSE
#else /* defined(OSX) */
#define J9_SHARED_CACHE_DEFAULT_BOOT_SHARING(vm) (J2SE_VERSION(vm) >= J2SE_V11)
#endif /* defined(OSX) */
#endif /* defined(OPENJ9_BUILD) && !defined(OSX) */

#endif /* J9_H */
7 changes: 5 additions & 2 deletions runtime/shared_common/OSCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,18 @@ SH_OSCache::getCacheDir(J9JavaVM* vm, const char* ctrlDirName, char* buffer, UDA
if (appendBaseDir) {
flags |= J9SHMEM_GETDIR_APPEND_BASEDIR;
}
if ((J2SE_VERSION(vm) >= J2SE_V11)
&& (NULL == ctrlDirName)

#if defined(OPENJ9_BUILD)
if ((NULL == ctrlDirName)
&& J9_ARE_NO_BITS_SET(vm->sharedCacheAPI->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_GROUP_ACCESS)
) {
/* j9shmem_getDir() always tries the CSIDL_LOCAL_APPDATA directory (C:\Documents and Settings\username\Local Settings\Application Data)
* first on Windows if ctrlDirName is NULL, regardless of whether J9SHMEM_GETDIR_USE_USERHOME is set or not. So J9SHMEM_GETDIR_USE_USERHOME is effective on UNIX only.
*/

flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#endif /*defined(OPENJ9_BUILD) */

rc = j9shmem_getDir(ctrlDirName, flags, buffer, bufferSize);
if (rc == -1) {
Expand Down
6 changes: 3 additions & 3 deletions runtime/tests/shared/CacheDirPerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ CacheDirPerm::getTempCacheDir(J9JavaVM *vm, I_32 cacheType, bool useDefaultDir)

if (useDefaultDir) {
flags |= J9SHMEM_GETDIR_APPEND_BASEDIR;
if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */
}

memset(cacheDir, 0, J9SH_MAXPATH);
Expand Down
12 changes: 6 additions & 6 deletions runtime/tests/shared/CorruptCacheTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,9 +815,9 @@ zeroOutCache(J9JavaVM *vm, I_32 cacheType)
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;
PORT_ACCESS_FROM_JAVAVM(vm);

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

rc = j9shmem_getDir(NULL, flags, baseDir, J9SH_MAXPATH);
if (rc == -1) {
Expand Down Expand Up @@ -881,9 +881,9 @@ truncateCache(J9JavaVM *vm, I_32 cacheType)
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;
PORT_ACCESS_FROM_JAVAVM(vm);

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

rc = j9shmem_getDir(NULL, flags, baseDir, J9SH_MAXPATH);
if (rc == -1) {
Expand Down
50 changes: 25 additions & 25 deletions runtime/tests/shared/OSCacheTestMmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ SH_OSCacheTestMmap::testBasic(J9PortLibrary *portLibrary, J9JavaVM *vm)
J9PortShcVersion versionData;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_PERSISTENT;
Expand Down Expand Up @@ -142,9 +142,9 @@ SH_OSCacheTestMmap::testConstructor(J9PortLibrary *portLibrary, J9JavaVM *vm)
J9PortShcVersion versionData;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_PERSISTENT;
Expand Down Expand Up @@ -214,9 +214,9 @@ SH_OSCacheTestMmap::testFailedConstructor(J9PortLibrary *portLibrary, J9JavaVM *
J9PortShcVersion versionData;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_PERSISTENT;
Expand Down Expand Up @@ -313,9 +313,9 @@ SH_OSCacheTestMmap::testMultipleCreate(J9PortLibrary* portLibrary, J9JavaVM *vm,
UDATA childargc = 0;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_PERSISTENT;
Expand Down Expand Up @@ -460,9 +460,9 @@ SH_OSCacheTestMmap::testGetAllCacheStatistics(J9JavaVM* vm)
}
piconfig->sharedClassDebugAreaBytes = -1;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

ret = j9shmem_getDir(ctrlDirName, flags, cacheDirName, J9SH_MAXPATH);
if (-1 == ret) {
Expand Down Expand Up @@ -570,9 +570,9 @@ SH_OSCacheTestMmap::testMutex(J9PortLibrary *portLibrary, J9JavaVM *vm, struct j
UDATA childargc = 0;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_PERSISTENT;
Expand Down Expand Up @@ -663,9 +663,9 @@ SH_OSCacheTestMmap::testMutexHang(J9PortLibrary *portLibrary, J9JavaVM *vm, stru
UDATA childargc = 0;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_PERSISTENT;
Expand Down Expand Up @@ -757,9 +757,9 @@ SH_OSCacheTestMmap::testDestroy (J9PortLibrary* portLibrary, J9JavaVM *vm, struc
UDATA childargc = 0;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_PERSISTENT;
Expand All @@ -770,7 +770,7 @@ SH_OSCacheTestMmap::testDestroy (J9PortLibrary* portLibrary, J9JavaVM *vm, struc
}
piconfig->sharedClassDebugAreaBytes = -1;

ret = j9shmem_getDir(NULL, J9SHMEM_GETDIR_APPEND_BASEDIR, cacheDir, J9SH_MAXPATH);
ret = j9shmem_getDir(NULL, flags, cacheDir, J9SH_MAXPATH);
if (-1 == ret) {
j9tty_printf(PORTLIB, "testDestroy: j9shmem_getDir() failed \n");
goto cleanup;
Expand Down
60 changes: 30 additions & 30 deletions runtime/tests/shared/OSCacheTestSysv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ SH_OSCacheTestSysv::testBasic(J9PortLibrary* portLibrary, J9JavaVM *vm)
char cacheDir[J9SH_MAXPATH];
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_NONPERSISTENT;
Expand Down Expand Up @@ -186,9 +186,9 @@ SH_OSCacheTestSysv::testMultipleCreate(J9PortLibrary* portLibrary, J9JavaVM *vm,
UDATA childargc = 0;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */
setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_NONPERSISTENT;

Expand Down Expand Up @@ -322,9 +322,9 @@ SH_OSCacheTestSysv::testConstructor(J9PortLibrary *portLibrary, J9JavaVM *vm)
J9PortShcVersion versionData;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */
setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_NONPERSISTENT;

Expand Down Expand Up @@ -406,9 +406,9 @@ SH_OSCacheTestSysv::testFailedConstructor(J9PortLibrary *portLibrary, J9JavaVM *
J9PortShcVersion versionData;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */
setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_NONPERSISTENT;

Expand Down Expand Up @@ -499,19 +499,19 @@ SH_OSCacheTestSysv::testGetAllCacheStatistics(J9JavaVM* vm)
goto cleanup;
}

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= (J9SHMEM_GETDIR_USE_USERHOME | J9SHMEM_GETDIR_APPEND_BASEDIR);
}
#if defined(OPENJ9_BUILD)
flags |= (J9SHMEM_GETDIR_USE_USERHOME | J9SHMEM_GETDIR_APPEND_BASEDIR);
#endif /* defined(OPENJ9_BUILD) */

ret = j9shmem_getDir(ctrlDirName, flags, cacheDirName, J9SH_MAXPATH);
if (-1 == ret) {
j9tty_printf(PORTLIB, "testGetAllCacheStatistics: j9shmem_getDir() failed \n");
goto cleanup;
}

if (J2SE_VERSION(vm) < J2SE_V11) {
testDir = cacheDirName;
}
#if !defined(OPENJ9_BUILD)
testDir = cacheDirName;
#endif /* !defined(OPENJ9_BUILD) */

/* Before starting existing caches must be cleaned up in case previous test runs failed to clean up (CMVC 167936).
* If any step fails the loop continues in order to 'get as much clean up as possible'.
Expand Down Expand Up @@ -615,9 +615,9 @@ SH_OSCacheTestSysv::testMutex(J9PortLibrary *portLibrary, J9JavaVM *vm, struct j
IDATA rc;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */
setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_NONPERSISTENT;

Expand Down Expand Up @@ -710,9 +710,9 @@ SH_OSCacheTestSysv::testMutexHang(J9PortLibrary *portLibrary, J9JavaVM *vm, stru
UDATA childargc = 0;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */
setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_NONPERSISTENT;

Expand Down Expand Up @@ -803,9 +803,9 @@ SH_OSCacheTestSysv::testSize(J9PortLibrary* portLibrary, J9JavaVM *vm)
J9PortShcVersion versionData;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */
setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_NONPERSISTENT;

Expand Down Expand Up @@ -959,9 +959,9 @@ SH_OSCacheTestSysv::testDestroy (J9PortLibrary* portLibrary, J9JavaVM *vm, struc
UDATA childargc = 0;
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */
setCurrentCacheVersion(vm, J2SE_LATEST, &versionData);
versionData.cacheType = J9PORT_SHR_CACHE_TYPE_NONPERSISTENT;

Expand Down
6 changes: 3 additions & 3 deletions runtime/tests/shared/SharedCacheAPITest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ getCacheDir(J9JavaVM *vm, char *cacheDir)
char cacheDirNoTestBasedir[J9SH_MAXPATH];
U_32 flags = J9SHMEM_GETDIR_APPEND_BASEDIR;

if (J2SE_VERSION(vm) >= J2SE_V11) {
flags |= J9SHMEM_GETDIR_USE_USERHOME;
}
#if defined(OPENJ9_BUILD)
flags |= J9SHMEM_GETDIR_USE_USERHOME;
#endif /* defined(OPENJ9_BUILD) */

rc = j9shmem_getDir(NULL, flags, cacheDirNoTestBasedir, J9SH_MAXPATH);
if (rc == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@
</groups>
<subsets>
<subset>SE110</subset>
<subset>SE80</subset>
</subsets>
<impls>
<impl>openj9</impl>
Expand Down

0 comments on commit d364857

Please sign in to comment.