Skip to content

Commit

Permalink
Merge pull request #16639 from pshipton/flagsfinal
Browse files Browse the repository at this point in the history
Show 0 for MaxDirectMemorySize with PrintFlagsFinal when unset
  • Loading branch information
keithc-ca committed Feb 7, 2023
2 parents d79a71c + 08802bc commit be89be0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions runtime/jcl/common/system.c
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1998, 2022 IBM Corp. and others
* Copyright (c) 1998, 2023 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 @@ -490,20 +490,20 @@ jobject getPropertyList(JNIEnv *env)

#if defined(OPENJ9_BUILD) && JAVA_SPEC_VERSION == 8
/* Set the maximum direct byte buffer allocation property if it has not been set manually */
if ((UDATA) -1 == javaVM->directByteBufferMemoryMax) {
if ((~(UDATA)0) == javaVM->directByteBufferMemoryMax) {
UDATA heapSize = javaVM->memoryManagerFunctions->j9gc_get_maximum_heap_size(javaVM);
/* allow up to 7/8 of the heap to be direct byte buffers */
javaVM->directByteBufferMemoryMax = heapSize - (heapSize / 8);
}
#endif /* defined(OPENJ9_BUILD) && JAVA_SPEC_VERSION == 8 */
#if !defined(OPENJ9_BUILD)
/* Don't set a default value for IBM Java 8. */
if ((UDATA) -1 != javaVM->directByteBufferMemoryMax)
if ((~(UDATA)0) != javaVM->directByteBufferMemoryMax)
#endif /* !defined(OPENJ9_BUILD) */
{
strings[propIndex] = "sun.nio.MaxDirectMemorySize";
propIndex += 1;
if ((UDATA) -1 == javaVM->directByteBufferMemoryMax) {
if ((~(UDATA)0) == javaVM->directByteBufferMemoryMax) {
strcpy(maxDirectMemBuff, "-1");
} else {
j9str_printf(PORTLIB, maxDirectMemBuff, sizeof(maxDirectMemBuff), "%zu", javaVM->directByteBufferMemoryMax);
Expand Down
4 changes: 2 additions & 2 deletions runtime/vm/jvminit.c
Expand Up @@ -2327,7 +2327,7 @@ VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved)
}

parseError = setMemoryOptionToOptElse(vm, &(vm->directByteBufferMemoryMax),
VMOPT_XXMAXDIRECTMEMORYSIZEEQUALS, (UDATA) -1, TRUE);
VMOPT_XXMAXDIRECTMEMORYSIZEEQUALS, ~(UDATA)0, TRUE);
if (OPTION_OK != parseError) {
parseErrorOption = VMOPT_XXMAXDIRECTMEMORYSIZEEQUALS;
goto _memParseError;
Expand Down Expand Up @@ -7291,7 +7291,7 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData)
IDATA disabled = FIND_AND_CONSUME_VMARG(EXACT_MATCH, VMOPT_XXPRINTFLAGSFINALDISABLE, NULL);
if (enabled > disabled) {
size_t maxHeapSize = (size_t) (vm->memoryManagerFunctions->j9gc_get_maximum_heap_size(vm));
uint64_t maxDirectMemorySize = (uint64_t) (vm->directByteBufferMemoryMax);
uint64_t maxDirectMemorySize = (uint64_t) (((~(UDATA)0) == vm->directByteBufferMemoryMax) ? 0 : vm->directByteBufferMemoryMax);
const char *howset = NULL;

/*
Expand Down

0 comments on commit be89be0

Please sign in to comment.