Skip to content

Commit

Permalink
Merge pull request #2929 from babsingh/macos_port_v2_pr
Browse files Browse the repository at this point in the history
OpenJ9 fixes for OSX support [Part 2]
  • Loading branch information
DanHeidinga authored Sep 20, 2018
2 parents f91e31c + 68b0c49 commit f499919
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 67 deletions.
20 changes: 12 additions & 8 deletions runtime/jcl/unix/syshelp.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,22 @@ void mapLibraryToPlatformName(const char *inPath, char *outPath) {
char *getPlatformFileEncoding(JNIEnv * env, char *codepageProp, int propSize, int encodingType)
{
#if defined(J9ZTPF)
return "ISO8859_1";
return "ISO8859_1";
#endif /* defined(J9ZTPF) */
PORT_ACCESS_FROM_ENV(env);
char *codepage;
int i, nameIndex;
char *codepage = NULL;
int i = 0;
int nameIndex = 0;
#if defined(LINUX)
IDATA result;
char langProp[24], *ctype;
#endif
IDATA result = 0;
char langProp[24] = {0};
char *ctype = NULL;
PORT_ACCESS_FROM_ENV(env);
#endif /* defined(LINUX) */

/* Called with codepageProp == NULL to initialize the locale */
if (!codepageProp) return NULL;
if (NULL == codepageProp) {
return NULL;
}

#ifdef LINUX
/*[PR 104520] Return EUC_JP when LC_CTYPE is not set, and the LANG environment variable is "ja" */
Expand Down
12 changes: 6 additions & 6 deletions runtime/rasdump/dmpsup.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ static void abortHandler (int sig);
static void initRasDumpGlobalStorage(J9JavaVM *vm);
static void freeRasDumpGlobalStorage(J9JavaVM *vm);
static void hookVmInitialized PROTOTYPE((J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData));
#ifdef LINUX
#if defined(LINUX)
static void appendSystemInfoFromFile(J9JavaVM *vm, U_32 key, const char *fileName );
#endif
#endif /* defined(LINUX) */
#ifdef J9ZOS390
static IDATA processZOSDumpOptions(J9JavaVM *vm, J9RASdumpOption* agentOpts, int optIndex);
static void triggerAbend(void);
Expand Down Expand Up @@ -1268,7 +1268,7 @@ initSystemInfo(J9JavaVM *vm)
}
}

#ifdef LINUX
#if defined(LINUX)
/* On Linux, store the startup value of /proc/sys/kernel/sched_compat_yield if it's set */
{
char schedCompatYieldValue = j9util_sched_compat_yield_value(vm);
Expand All @@ -1287,7 +1287,7 @@ initSystemInfo(J9JavaVM *vm)
}
appendSystemInfoFromFile(vm, J9RAS_SYSTEMINFO_CORE_PATTERN, J9RAS_CORE_PATTERN_FILE);
appendSystemInfoFromFile(vm, J9RAS_SYSTEMINFO_CORE_USES_PID, J9RAS_CORE_USES_PID_FILE);
#endif
#endif /* defined(LINUX) */
}

/**
Expand Down Expand Up @@ -1325,7 +1325,7 @@ initDumpDirectory(J9JavaVM *vm)
return retVal;
}


#if defined(LINUX)
/* Adds a J9RASSystemInfo to the end of the system info list using the key
* specified as the key and the data from the specified file in /proc if
* it exists.
Expand Down Expand Up @@ -1382,7 +1382,7 @@ appendSystemInfoFromFile(J9JavaVM *vm, U_32 key, const char *fileName )
j9file_close(fd);
}
}

#endif /* defined(LINUX) */

IDATA
J9VMDllMain(J9JavaVM *vm, IDATA stage, void *reserved)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ cbMethodEntry(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID me
return;
}
}
(*jvmti_env)->Deallocate(jvmti_env, name_ptr);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)name_ptr);

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ testFollowReferences_heapRefCallback(jvmtiHeapReferenceKind refKind,
static void *
getArrayElements(JNIEnv * jni_env, jvmtiPrimitiveType primitiveType, jint primitiveArraySize, jobject array)
{
void * arrayElements;
void *arrayElements = NULL;

switch (primitiveType) {
case JVMTI_PRIMITIVE_TYPE_BOOLEAN:
Expand All @@ -241,6 +241,9 @@ getArrayElements(JNIEnv * jni_env, jvmtiPrimitiveType primitiveType, jint primit
case JVMTI_PRIMITIVE_TYPE_DOUBLE:
arrayElements = (*jni_env)->GetDoubleArrayElements(jni_env, array, NULL);
break;
default:
error(_agentEnv, JVMTI_ERROR_INTERNAL, "Unknown array primitive value type [%d]", primitiveType);
break;
}

return arrayElements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ testForceEarlyReturn_methodEntry(jvmtiEnv * jvmti_env, JNIEnv * jni_env, jthread
{
jvmtiError err;
testForceEarlyReturn_testTrigger *trigger;
unsigned char * methName = NULL;
unsigned char * threadName = NULL;
unsigned char * suspThreadName = NULL;
agentEnv * env = _agentEnv;
char *methName = NULL;
char *threadName = NULL;
char *suspThreadName = NULL;
agentEnv *env = _agentEnv;

methName = testForceEarlyReturn_getMethodName(env, method);

Expand Down Expand Up @@ -288,7 +288,7 @@ testForceEarlyReturn_waitForTestThread(agentEnv * env, jthread thread, jmethodID
!strcmp(thrName, "Thread-Runner")) {
unsigned char * suspendedThreadName;
*suspendedThread = threads[i];
suspendedThreadName = getThreadName(env, thread, *suspendedThread),
suspendedThreadName = (unsigned char *)getThreadName(env, thread, *suspendedThread),
tprintf(env, 300,
"\t%-10s state 0x%x thr 0x%x susThr 0x%p i%d is SUSPENDED. returning\n",
suspendedThreadName, state, thread, threads[i], i);
Expand Down Expand Up @@ -375,10 +375,10 @@ testForceEarlyReturn_getMethodName(agentEnv * env, jmethodID method)
goto done;
}

strcpy(name, declaringClassName);
strcat(name, ".");
strcat(name, methodName);
strcat(name, methodSig);
strcpy((char *)name, declaringClassName);
strcat((char *)name, ".");
strcat((char *)name, methodName);
strcat((char *)name, methodSig);

done:

Expand All @@ -392,5 +392,5 @@ testForceEarlyReturn_getMethodName(agentEnv * env, jmethodID method)
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *) declaringClassName);


return name;
return (char *)name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static jint testGetAllStackTracesExtended(JavaVM * vm, jvmtiEnv * jvmti_env, jin
++num_jitted;
}
}
(*jvmti_env)->Deallocate(jvmti_env, (char *)psiExt);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)psiExt);

if ( high && (num_jitted == 0) ) {
rc = JNI_ERR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ Java_com_ibm_jvmti_tests_getClassFields_gcf001_checkClassFields(JNIEnv *jni_env,
return JNI_FALSE;
}

(*jvmti_env)->Deallocate(jvmti_env, fieldName);
(*jvmti_env)->Deallocate(jvmti_env, fieldSignature);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)fieldName);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)fieldSignature);
(*jni_env)->ReleaseStringUTFChars(jni_env, expectedNameString, expectedName);
(*jni_env)->ReleaseStringUTFChars(jni_env, expectedSignatureString, expectedSignature);
}
(*jvmti_env)->Deallocate(jvmti_env, (char *)fields);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)fields);

return JNI_TRUE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ gmc001(agentEnv * agent_env, char * args)
fprintf(stderr,"gmc001: setting getMemoryCategories extension to %p\n", getMemoryCategories);
}

err = (*jvmti_env)->Deallocate(jvmti_env, extensions[i].id);
err = (*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)extensions[i].id);

if (err != JVMTI_ERROR_NONE) {
error(env, JVMTI_ERROR_NOT_FOUND, "gmc001:Couldn't Deallocate extensions[%d].id\n", i);
rc = JNI_ERR;
}

err = (*jvmti_env)->Deallocate(jvmti_env, extensions[i].short_description);
err = (*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)extensions[i].short_description);

if (err != JVMTI_ERROR_NONE) {
error(env, JVMTI_ERROR_NOT_FOUND, "gmc001:Couldn't Deallocate extensions[%d].short_description\n", i);
rc = JNI_ERR;
}

for (j = 0; j < extensions[i].param_count; j++) {
err = (*jvmti_env)->Deallocate(jvmti_env, extensions[i].params[j].name);
err = (*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)extensions[i].params[j].name);

if (err != JVMTI_ERROR_NONE) {
error(env, JVMTI_ERROR_NOT_FOUND, "gmc001:Couldn't Deallocate extensions[%d].params[%d].name\n", i, j);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ digForStackDepth(jthread thread, char *methodName, char * methodSignature)
depth = i;
i = count;
}
(*jvmti_env)->Deallocate(jvmti_env, name);
(*jvmti_env)->Deallocate(jvmti_env, sig);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)name);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)sig);
}

return depth;
Expand Down Expand Up @@ -169,9 +169,9 @@ getVariableSlotNumber(JNIEnv *jni_env, jclass clazz, char * varName, char * meth
slotIndex = table[i].slot;
/*printf("got slot at i=%d, slot=%d\n", i, slotIndex);*/
}
(*jvmti_env)->Deallocate(jvmti_env, table[i].name);
(*jvmti_env)->Deallocate(jvmti_env, table[i].signature);
(*jvmti_env)->Deallocate(jvmti_env, table[i].generic_signature);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)table[i].name);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)table[i].signature);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)table[i].generic_signature);
}

(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *) table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ getChildInfo(JNIEnv *jni_env, jthreadGroup *group)
}

if (JNI_OK == (*jvmti_env)->GetThreadGroupInfo(jvmti_env, *group, &groupInfo)) {
(*jvmti_env)->Deallocate(jvmti_env, groupInfo.name);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)groupInfo.name);
}

if (JNI_OK == (*jvmti_env)->GetThreadGroupChildren(jvmti_env, *group, &thread_cnt, &threads_p, &group_cnt, &groups_p)) {
Expand All @@ -68,16 +68,16 @@ getChildInfo(JNIEnv *jni_env, jthreadGroup *group)

for (i = 1; i <= thread_cnt; i++) {
if (JNI_OK == (*jvmti_env)->GetThreadInfo(jvmti_env, *thread_ptr, &threadInfo)) {
(*jvmti_env)->Deallocate(jvmti_env, threadInfo.name);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)threadInfo.name);
}
}

for (i = 1; i <= group_cnt; i++) {
getChildInfo(jni_env, group_ptr);
group_ptr++;
}
(*jvmti_env)->Deallocate(jvmti_env, (char *) groups_p);
(*jvmti_env)->Deallocate(jvmti_env, (char *) threads_p);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)groups_p);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)threads_p);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static jint testGetThreadListStackTracesExtended(JavaVM * vm, jvmtiEnv * jvmti_e
++num_jitted;
}
}
(*jvmti_env)->Deallocate(jvmti_env, (char *)psiExt);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)psiExt);

if ( high && (num_jitted == 0) ) {
rc = JNI_ERR;
Expand All @@ -188,7 +188,7 @@ static jint testGetThreadListStackTracesExtended(JavaVM * vm, jvmtiEnv * jvmti_e
"getThreadListTracesExtended: Error when high iteration count");
}
}
(*jvmti_env)->Deallocate(jvmti_env, (char *)thrds);
(*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)thrds);
return(rc);
}

Expand Down
46 changes: 23 additions & 23 deletions runtime/tests/shared/CompositeCacheTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2017 IBM Corp. and others
* Copyright (c) 2001, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -248,20 +248,20 @@ CompositeCacheTest::allocateAndStats(J9JavaVM* vm, IDATA testCacheSize, SH_Compo
cc1->enterWriteMutex(vm->mainThread, false, "allocateAndStats");

/* Check all is 0'd */
if (result |= localTestStats(vm, testCacheSize, 0, 0, 0, 0, 0, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, 0, 0, 0, 0, 0, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, 0, 0, 0, 0, 0, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, 0, 0, 0, 0, 0, cc1a, cacheBase))) goto _done;

itemPtr->dataLen = 64;

address = cc1->allocateWithSegment(vm->mainThread, itemPtr, 0, &segBuf);
if (result |= localTestStats(vm, testCacheSize, 0, 0, 0, 0, 0, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, 0, 0, 0, 0, 0, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, 0, 0, 0, 0, 0, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, 0, 0, 0, 0, 0, cc1a, cacheBase))) goto _done;

/* Stats should not be updated until update is committed */
cc1->commitUpdate(vm->mainThread, false);
runningTotal += itemPtr->dataLen;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 0, 0, 0, 1, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 0, 0, 0, 1, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 0, 0, 0, 1, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 0, 0, 0, 1, cc1a, cacheBase))) goto _done;

if (cc1->isAddressInROMClassSegment(address)) {
j9tty_printf(PORTLIB, "Address %p should not be in romclass segment\n", address);
Expand All @@ -275,12 +275,12 @@ CompositeCacheTest::allocateAndStats(J9JavaVM* vm, IDATA testCacheSize, SH_Compo
}

address = cc1->allocateWithSegment(vm->mainThread, itemPtr, 256, &segBuf);
if (result |= localTestStats(vm, testCacheSize, runningTotal, 0, 0, 0, 1, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 0, 0, 0, 1, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 0, 0, 0, 1, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 0, 0, 0, 1, cc1a, cacheBase))) goto _done;
cc1->commitUpdate(vm->mainThread, false);
runningTotal += itemPtr->dataLen;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 256, 0, 0, 2, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 256, 0, 0, 2, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 256, 0, 0, 2, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 256, 0, 0, 2, cc1a, cacheBase))) goto _done;

if (cc1->isAddressInROMClassSegment(address)) {
j9tty_printf(PORTLIB, "Address %p should not be in romclass segment\n", address);
Expand All @@ -296,12 +296,12 @@ CompositeCacheTest::allocateAndStats(J9JavaVM* vm, IDATA testCacheSize, SH_Compo
itemPtr->dataLen = 32;

address = cc1->allocateWithSegment(vm->mainThread, itemPtr, 8, &segBuf);
if (result |= localTestStats(vm, testCacheSize, runningTotal, 256, 0, 0, 2, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 256, 0, 0, 2, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 256, 0, 0, 2, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 256, 0, 0, 2, cc1a, cacheBase))) goto _done;
cc1->commitUpdate(vm->mainThread, false);
runningTotal += itemPtr->dataLen;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 3, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 3, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 3, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 3, cc1a, cacheBase))) goto _done;
if (cc1->isAddressInROMClassSegment(address)) {
j9tty_printf(PORTLIB, "Address %p should not be in romclass segment\n", address);
result = 10;
Expand All @@ -316,12 +316,12 @@ CompositeCacheTest::allocateAndStats(J9JavaVM* vm, IDATA testCacheSize, SH_Compo
itemPtr->dataLen = 100;

address = cc1->allocateBlock(vm->mainThread, itemPtr, SHC_WORDALIGN, 0);
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 3, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 3, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 3, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 3, cc1a, cacheBase))) goto _done;
cc1->commitUpdate(vm->mainThread, false);
runningTotal += itemPtr->dataLen;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 4, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 4, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 4, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 4, cc1a, cacheBase))) goto _done;
if (cc1->isAddressInROMClassSegment(address)) {
j9tty_printf(PORTLIB, "Address %p should not be in romclass segment\n", address);
result = 16;
Expand All @@ -331,12 +331,12 @@ CompositeCacheTest::allocateAndStats(J9JavaVM* vm, IDATA testCacheSize, SH_Compo
itemPtr->dataLen = 128;

address = cc1->allocateAOT(vm->mainThread, itemPtr, 96);
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 4, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 4, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 4, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 0, 0, 4, cc1a, cacheBase))) goto _done;
cc1->commitUpdate(vm->mainThread, false);
runningTotal += itemPtr->dataLen - 96;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 96, 0, 5, cc1, cacheBase)) goto _done;
if (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 96, 0, 5, cc1a, cacheBase)) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 96, 0, 5, cc1, cacheBase))) goto _done;
if (0 != (result |= localTestStats(vm, testCacheSize, runningTotal, 264, 96, 0, 5, cc1a, cacheBase))) goto _done;
if (cc1->isAddressInROMClassSegment(address)) {
j9tty_printf(PORTLIB, "Address %p should not be in romclass segment\n", address);
result = 17;
Expand Down

0 comments on commit f499919

Please sign in to comment.