2727# ----------------------------------------------------------------------------------------------------
2828import os
2929import re
30- import tempfile
31- import json
32- from genericpath import exists
3330from os .path import basename , dirname , getsize , join
3431from traceback import print_tb
3532import inspect
@@ -149,10 +146,6 @@ def __init__(self, vm, bm_suite, args):
149146 'extra-agent-profile-run-arg' , 'benchmark-output-dir' , 'stages' , 'skip-agent-assertions' ]
150147 self .profile_file_extension = '.iprof'
151148 self .stages = bm_suite .stages (args )
152- if vm .jdk_profiles_collect : # forbid image build/run in the profile collection execution mode
153- for stage in ('image' , 'run' ):
154- if stage in self .stages :
155- self .stages .remove (stage )
156149 self .last_stage = self .stages [- 1 ]
157150 self .skip_agent_assertions = bm_suite .skip_agent_assertions (self .benchmark_name , args )
158151 self .root_dir = self .benchmark_output_dir if self .benchmark_output_dir else mx .suite ('vm' ).get_output_root (platformDependent = False , jdkDependent = False )
@@ -218,8 +211,6 @@ def __init__(self, name, config_name, extra_java_args=None, extra_launcher_args=
218211 self .config = None
219212 self .stages = None
220213 self .ml = None
221- self .jdk_profiles_collect = False
222- self .cached_jdk_pgo = False
223214 self .analysis_context_sensitivity = None
224215 self .no_inlining_before_analysis = False
225216 self ._configure_from_name (config_name )
@@ -240,7 +231,7 @@ def _configure_from_name(self, config_name):
240231
241232 # This defines the allowed config names for NativeImageVM. The ones registered will be available via --jvm-config
242233 rule = r'^(?P<native_architecture>native-architecture-)?(?P<string_inlining>string-inlining-)?(?P<gate>gate-)?(?P<upx>upx-)?(?P<quickbuild>quickbuild-)?(?P<gc>g1gc-)?(?P<llvm>llvm-)?(?P<pgo>pgo-|pgo-ctx-insens-)?(?P<inliner>aot-inline-|iterative-|inline-explored-)?' \
243- r'(?P<analysis_context_sensitivity>insens-|allocsens-|1obj-|2obj1h-|3obj2h-|4obj3h-)?(?P<no_inlining_before_analysis>no-inline-)?(?P<ml>ml-profile-inference-)?(?P<jdk_profiles>jdk-profiles-collect-|cached-jdk-pgo-)?(?P< edition>ce-|ee-)?$'
234+ r'(?P<analysis_context_sensitivity>insens-|allocsens-|1obj-|2obj1h-|3obj2h-|4obj3h-)?(?P<no_inlining_before_analysis>no-inline-)?(?P<ml>ml-profile-inference-)?(?P<edition>ce-|ee-)?$'
244235
245236 mx .logv ("== Registering configuration: {}" .format (config_name ))
246237 match_name = "{}-" .format (config_name ) # adding trailing dash to simplify the regex
@@ -311,42 +302,6 @@ def _configure_from_name(self, config_name):
311302 if matching .group ("ml" ) is not None :
312303 self .ml = matching .group ("ml" )[:- 1 ]
313304
314- if matching .group ("jdk_profiles" ) is not None :
315- config = matching .group ("jdk_profiles" )[:- 1 ]
316- if config == 'jdk-profiles-collect' :
317- self .jdk_profiles_collect = True
318- self .pgo_instrumented_iterations = 1
319-
320- def generate_profiling_package_prefixes ():
321- # run the native-image-configure tool to gather the jdk package prefixes
322- native_image_configure_command = mx .cmd_suffix (join (mx_sdk_vm .graalvm_home (), 'bin' , 'native-image-configure' ))
323- if not exists (native_image_configure_command ):
324- mx .abort ('Failed to find the native-image-configure command at {}.' .format (native_image_configure_command ))
325- tmp = tempfile .NamedTemporaryFile ()
326- ret = mx .run ([native_image_configure_command , 'generate-filters' ,
327- '--include-packages-from-modules=java.base' ,
328- '--exclude-classes=org.graalvm.**' , '--exclude-classes=com.oracle.**' , # remove internal packages
329- '--output-file={}' .format (tmp .name )], nonZeroIsFatal = True )
330- if ret != 0 :
331- mx .abort ('Native image configure command failed.' )
332-
333- # format the profiling package prefixes
334- with open (tmp .name , 'r' ) as f :
335- prefixes = json .loads (f .read ())
336- if 'rules' not in prefixes :
337- mx .abort ('Native image configure command failed. Can not generate rules.' )
338- rules = prefixes ['rules' ]
339- rules = map (lambda r : r ['includeClasses' ][:- 2 ], filter (lambda r : 'includeClasses' in r , rules ))
340- return ',' .join (rules )
341- self .generate_profiling_package_prefixes = generate_profiling_package_prefixes
342- elif config == 'cached-jdk-pgo' :
343- self .cached_jdk_pgo = True
344- else :
345- mx .abort ('Unknown jdk profiles configuration: {}' .format (config ))
346- # choose appropriate profiles
347- jdk_profiles = 'JDK{}_PROFILES' .format (str (mx .get_jdk ().version ).split ('.' )[0 ])
348- self .cached_profiles_base_dir = mx .library (jdk_profiles ).get_path (True )
349-
350305 if matching .group ("edition" ) is not None :
351306 edition = matching .group ("edition" )[:- 1 ]
352307 mx .logv ("GraalVM edition is set to: {}" .format (edition ))
@@ -818,8 +773,6 @@ def run_stage_instrument_image(self, config, stages, out, i, instrumentation_ima
818773 pgo_args += ['-H:' + ('+' if self .pgo_context_sensitive else '-' ) + 'PGOContextSensitivityEnabled' ]
819774 pgo_args += ['-H:+AOTInliner' ] if self .pgo_aot_inline else ['-H:-AOTInliner' ]
820775 instrument_args = ['--pgo-instrument' ] + ([] if i == 0 else pgo_args )
821- if self .jdk_profiles_collect :
822- instrument_args += ['-H:+ProfilingEnabled' , '-H:+AOTPriorityInline' , '-H:ProfilingPackagePrefixes={}' .format (self .generate_profiling_package_prefixes ())]
823776
824777 with stages .set_command (config .base_image_build_args + executable_name_args + instrument_args ) as s :
825778 s .execute_command ()
@@ -844,12 +797,7 @@ def run_stage_image(self, config, stages):
844797 pgo_args += ['-H:+AOTInliner' ] if self .pgo_aot_inline else ['-H:-AOTInliner' ]
845798 instrumented_iterations = self .pgo_instrumented_iterations if config .pgo_iteration_num is None else int (config .pgo_iteration_num )
846799 ml_args = ['-H:+ProfileInference' ] if self .ml == 'ml-profile-inference' else []
847- if self .cached_jdk_pgo :
848- cached_profiles = ',' .join (list (map (lambda f : os .path .join (self .cached_profiles_base_dir , f ), os .listdir (self .cached_profiles_base_dir ))))
849- jdk_profiles_args = ['-H:CachedPGOEnabled={}' .format (cached_profiles )]
850- else :
851- jdk_profiles_args = []
852- final_image_command = config .base_image_build_args + executable_name_args + (pgo_args if instrumented_iterations > 0 else []) + ml_args + jdk_profiles_args
800+ final_image_command = config .base_image_build_args + executable_name_args + (pgo_args if instrumented_iterations > 0 else []) + ml_args
853801 with stages .set_command (final_image_command ) as s :
854802 s .execute_command ()
855803 if self .use_upx :
0 commit comments