@@ -544,26 +544,101 @@ def __init__(self, name, config_name, extra_java_args=None, extra_launcher_args=
544544 self .analysis_context_sensitivity = None
545545 self .no_inlining_before_analysis = False
546546 self .optimization_level = None
547- self ._configure_from_name (config_name )
547+ self ._configure_comma_separated_configs (config_name )
548+ if ',' in config_name :
549+ self ._canonical_configuration = False
550+ else :
551+ # we validate that programmatic configuration of the VM matches reliably re-generates the original config name
552+ # since this feature is relied upon for syntactic sugar for vm configs
553+ assert config_name == self .config_name (), f"Config name mismatch: '{ config_name } ' is generated as '{ self .config_name ()} ' !"
554+
555+ @staticmethod
556+ def canonical_config_name (config_name ):
557+ # NativeImageVM allows syntactic sugar for its VM configs such that 'otw-ee,pgo,g1gc' is mapped to 'otw-g1gc-pgo-ee'
558+ # this canonicalization will take the former and return the latter
559+ return NativeImageVM ('native-image' , config_name ).config_name ()
560+
561+ def config_name (self ):
562+ # Generates the unique vm config name based on how the VM is actually configured.
563+ # It concatenates the config options in the correct order to match the expected format.
564+ config = []
565+ if self .native_architecture is True :
566+ config += ["native-architecture" ]
567+ if self .use_string_inlining is True :
568+ config += ["string-inlining" ]
569+ if self .use_open_type_world is True :
570+ config += ["otw" ]
571+ if self .is_gate is True :
572+ config += ["gate" ]
573+ if self .use_upx is True :
574+ config += ["upx" ]
575+ if self .is_quickbuild is True :
576+ config += ["quickbuild" ]
577+ if self .gc == "G1" :
578+ config += ["g1gc" ]
579+ if self .is_llvm is True :
580+ config += ["llvm" ]
581+ is_pgo_set = False
582+ if self .pgo_context_sensitive is False :
583+ config += ["pgo-ctx-insens" ]
584+ is_pgo_set = True
585+ if self .pgo_sampler_only is True :
586+ config += ["pgo-sampler" ]
587+ is_pgo_set = True
588+ # pylint: disable=too-many-boolean-expressions
589+ if not is_pgo_set and self .pgo_instrumentation is True \
590+ and self .jdk_profiles_collect is False \
591+ and self .adopted_jdk_pgo is False \
592+ and self .safepoint_sampler is False \
593+ and self .async_sampler is False \
594+ and self .force_profile_inference is False \
595+ and self .profile_inference_feature_extraction is False :
596+ config += ["pgo" ]
597+ if self .analysis_context_sensitivity is not None :
598+ sensitivity = self .analysis_context_sensitivity
599+ if sensitivity .startswith ("_" ):
600+ sensitivity = sensitivity [1 :]
601+ config += [sensitivity ]
602+ if self .no_inlining_before_analysis is True :
603+ config += ["no-inline" ]
604+ if self .jdk_profiles_collect is True :
605+ config += ["jdk-profiles-collect" ]
606+ if self .adopted_jdk_pgo is True :
607+ config += ["adopted-jdk-pgo" ]
608+ if self .profile_inference_feature_extraction is True :
609+ config += ["profile-inference-feature-extraction" ]
610+ if self .pgo_instrumentation is True and self .force_profile_inference is True :
611+ if self .pgo_exclude_conditional is True :
612+ config += ["profile-inference-pgo" ]
613+ if self .profile_inference_debug is True :
614+ config += ["profile-inference-debug" ]
615+ if self .safepoint_sampler is True :
616+ config += ["safepoint-sampler" ]
617+ if self .async_sampler is True :
618+ config += ["async-sampler" ]
619+ if self .optimization_level is not None :
620+ config += [self .optimization_level ]
621+ if not config :
622+ config += ["default" ]
623+ if self .graalvm_edition is not None :
624+ config += [self .graalvm_edition ]
625+ return "-" .join (config )
626+
627+ def _configure_comma_separated_configs (self , config_string ):
628+ # Due to the complexity of the VM config and how hard it is to get the ordering right, it has been relaxed
629+ # to allow comma-separated configs. So 'pgo,g1gc-ee,native-architecture' is syntactic sugar for 'native-architecture-g1gc-pgo-ee'
630+ for config_part in config_string .split (',' ):
631+ if config_part :
632+ self ._configure_from_name (config_part )
548633
549634 def _configure_from_name (self , config_name ):
550635 if not config_name :
551636 mx .abort (f"config_name must be set. Use 'default' for the default { self .__class__ .__name__ } configuration." )
552637
553- # special case for the 'default' configuration, other configurations are handled by the regex to ensure consistent ordering
554- if config_name == "default" :
555- return
556- if config_name == "default-ce" :
557- self .graalvm_edition = "ce"
558- return
559- if config_name == "default-ee" :
560- self .graalvm_edition = "ee"
561- return
562-
563638 # This defines the allowed config names for NativeImageVM. The ones registered will be available via --jvm-config
564639 rule = r'^(?P<native_architecture>native-architecture-)?(?P<string_inlining>string-inlining-)?(?P<otw>otw-)?(?P<gate>gate-)?(?P<upx>upx-)?(?P<quickbuild>quickbuild-)?(?P<gc>g1gc-)?(?P<llvm>llvm-)?(?P<pgo>pgo-|pgo-ctx-insens-|pgo-sampler-)?(?P<inliner>inline-)?' \
565640 r'(?P<analysis_context_sensitivity>insens-|allocsens-|1obj-|2obj1h-|3obj2h-|4obj3h-)?(?P<no_inlining_before_analysis>no-inline-)?(?P<jdk_profiles>jdk-profiles-collect-|adopted-jdk-pgo-)?' \
566- r'(?P<profile_inference>profile-inference-feature-extraction-|profile-inference-pgo-|profile-inference-debug-)?(?P<sampler>safepoint-sampler-|async-sampler-)?(?P<optimization_level>O0-|O1-|O2-|O3-|Os-)?(?P<edition>ce-|ee-)?$'
641+ r'(?P<profile_inference>profile-inference-feature-extraction-|profile-inference-pgo-|profile-inference-debug-)?(?P<sampler>safepoint-sampler-|async-sampler-)?(?P<optimization_level>O0-|O1-|O2-|O3-|Os-)?(default-)?( ?P<edition>ce-|ee-)?$'
567642
568643 mx .logv (f"== Registering configuration: { config_name } " )
569644 match_name = f"{ config_name } -" # adding trailing dash to simplify the regex
0 commit comments