Path: blob/master/runtime/gc_modron_startup/mmparseXgcpolicy.cpp
5986 views
1/*******************************************************************************2* Copyright (c) 1991, 2018 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception21*******************************************************************************/2223/**24* @file25* @ingroup GC_Modron_Startup26*/2728#include "j9.h"29#include "j9cfg.h"30#include "j2sever.h"31#include "jvminit.h"32#include "mmparse.h"3334#include "Configuration.hpp"35#include "GCExtensions.hpp"3637#include <string.h>3839bool MMINLINE40isOptthruputGCPolicySupported(MM_GCExtensions *extensions)41{42#if defined(J9VM_GC_MODRON_STANDARD)43return true;44#endif /* J9VM_GC_MODRON_STANDARD */45return false;46}4748bool MMINLINE49isNoGcGCPolicySupported(MM_GCExtensions *extensions)50{51return true;52}5354bool MMINLINE55isOptavgpauseGCPolicySupported(MM_GCExtensions *extensions)56{57#if defined(J9VM_GC_MODRON_STANDARD)58return true;59#endif /* J9VM_GC_MODRON_STANDARD */60return false;61}6263bool MMINLINE64isGenconGCPolicySupported(MM_GCExtensions *extensions)65{66#if defined(J9VM_GC_MODRON_STANDARD) && defined(J9VM_GC_GENERATIONAL)67return true;68#endif /* J9VM_GC_MODRON_STANDARD && J9VM_GC_GENERATIONAL */69return false;70}7172bool MMINLINE73isSubpoolAliasGCPolicySupported(MM_GCExtensions *extensions)74{75#if defined(J9VM_GC_MODRON_STANDARD) && defined(J9VM_GC_SUBPOOLS_ALIAS)76return true;77#endif /* J9VM_GC_MODRON_STANDARD && J9VM_GC_SUBPOOLS_ALIAS */78return false;79}8081bool MMINLINE82isMetronomeGCPolicySupported(MM_GCExtensions *extensions)83{84#if defined(J9VM_GC_REALTIME)85#if defined(AIXPPC)86return true;87#elif defined(LINUX) && (defined(J9HAMMER) || defined(J9X86))88return true;89#endif90#endif /* J9VM_GC_REALTIME */91return false;92}9394bool MMINLINE95isBalancedGCPolicySupported(MM_GCExtensions *extensions)96{97#if defined (J9VM_GC_VLHGC) && defined (J9VM_ENV_DATA64)98return true;99#endif /* J9VM_GC_VLHGC && J9VM_ENV_DATA64 */100return false;101}102103/**104* Consume -Xgcpolicy: arguments.105* support -XX:+UseNoGC option for compatibility106*107* For compatibility with previous versions multiple gc policy specifications allowed:108* last one wins109*/110void111gcParseXgcpolicy(MM_GCExtensions *extensions)112{113J9JavaVM *vm = (J9JavaVM *)extensions->getOmrVM()->_language_vm;114J9VMInitArgs *vmArgs = vm->vmArgsArray;115bool enableUnsupported = false;116117IDATA xgcpolicyIndex = FIND_ARG_IN_VMARGS_FORWARD( STARTSWITH_MATCH, "-Xgcpolicy:", NULL );118IDATA lastXgcpolicyIndex = 0;119while (xgcpolicyIndex >= 0) {120char *policy = NULL;121GET_OPTION_VALUE( xgcpolicyIndex, ':', &policy);122123if (NULL != policy) {124if (0 == strcmp("enableUnsupported", policy)) {125/* -Xgcpolicy:enableUnsupported permits selection of GC policies which aren't officially supported. */126CONSUME_ARG(vmArgs, xgcpolicyIndex);127enableUnsupported = true;128} else if (0 == strcmp("disableUnsupported", policy)) {129CONSUME_ARG(vmArgs, xgcpolicyIndex);130enableUnsupported = false;131} else {132lastXgcpolicyIndex = xgcpolicyIndex;133if (0 == strcmp("optthruput", policy)) {134if (isOptthruputGCPolicySupported(extensions) || enableUnsupported) {135CONSUME_ARG(vmArgs, xgcpolicyIndex);136extensions->configurationOptions._gcPolicy = gc_policy_optthruput;137}138} else if (0 == strcmp("subpool", policy)) {139if (isSubpoolAliasGCPolicySupported(extensions) || enableUnsupported) {140CONSUME_ARG(vmArgs, xgcpolicyIndex);141/* subpool is not supported anymore, use optthruput instead */142extensions->configurationOptions._gcPolicy = gc_policy_optthruput;143}144} else if (0 == strcmp("optavgpause", policy)) {145if (isOptavgpauseGCPolicySupported(extensions) || enableUnsupported) {146CONSUME_ARG(vmArgs, xgcpolicyIndex);147extensions->configurationOptions._gcPolicy = gc_policy_optavgpause;148}149} else if (0 == strcmp("gencon", policy)) {150if (isGenconGCPolicySupported(extensions) || enableUnsupported) {151CONSUME_ARG(vmArgs, xgcpolicyIndex);152extensions->configurationOptions._gcPolicy = gc_policy_gencon;153}154} else if (0 == strcmp("metronome", policy)) {155if (isMetronomeGCPolicySupported(extensions) || enableUnsupported) {156CONSUME_ARG(vmArgs, xgcpolicyIndex);157extensions->configurationOptions._gcPolicy = gc_policy_metronome;158}159} else if (0 == strcmp("balanced", policy)) {160if (isBalancedGCPolicySupported(extensions) || enableUnsupported) {161CONSUME_ARG(vmArgs, xgcpolicyIndex);162extensions->configurationOptions._gcPolicy = gc_policy_balanced;163}164} else if (0 == strcmp("nogc", policy)) {165if (isNoGcGCPolicySupported(extensions) || enableUnsupported) {166CONSUME_ARG(vmArgs, xgcpolicyIndex);167extensions->configurationOptions._gcPolicy = gc_policy_nogc;168}169}170}171}172173xgcpolicyIndex = FIND_NEXT_ARG_IN_VMARGS_FORWARD( STARTSWITH_MATCH, "-Xgcpolicy:", NULL, xgcpolicyIndex);174}175176IDATA xxUseNoGCIndex = FIND_AND_CONSUME_ARG(STARTSWITH_MATCH, "-XX:+UseNoGC", NULL);177if (xxUseNoGCIndex > lastXgcpolicyIndex) {178if (isNoGcGCPolicySupported(extensions) || enableUnsupported) {179extensions->configurationOptions._gcPolicy = gc_policy_nogc;180}181}182}183184185