3131import mx
3232import mx_benchmark
3333import mx_sdk_benchmark
34- import mx_compiler
35- from mx_java_benchmarks import DaCapoBenchmarkSuite , ScalaDaCapoBenchmarkSuite
3634from mx_benchmark import DataPoints
37- from mx_sdk_benchmark import SUCCESSFUL_STAGE_PATTERNS , Stage
35+ from mx_sdk_benchmark import DaCapoBenchmarkSuite , ScalaDaCapoBenchmarkSuite
36+ from mx_sdk_benchmark import JvmciJdkVm , SUCCESSFUL_STAGE_PATTERNS , Stage
3837
3938_suite = mx .suite ('compiler' )
4039
41- class JvmciJdkVm (mx_benchmark .OutputCapturingJavaVm ):
42- def __init__ (self , raw_name , raw_config_name , extra_args ):
43- super (JvmciJdkVm , self ).__init__ ()
44- self .raw_name = raw_name
45- self .raw_config_name = raw_config_name
46- self .extra_args = extra_args
47-
48- def name (self ):
49- return self .raw_name
50-
51- def config_name (self ):
52- return self .raw_config_name
53-
54- def post_process_command_line_args (self , args ):
55- return [arg if not callable (arg ) else arg () for arg in self .extra_args ] + args
56-
57- def get_jdk (self ):
58- tag = mx .get_jdk_option ().tag
59- if tag and tag != mx_compiler ._JVMCI_JDK_TAG :
60- mx .abort ("The '{0}/{1}' VM requires '--jdk={2}'" .format (
61- self .name (), self .config_name (), mx_compiler ._JVMCI_JDK_TAG ))
62- return mx .get_jdk (tag = mx_compiler ._JVMCI_JDK_TAG )
63-
64- def run_java (self , args , out = None , err = None , cwd = None , nonZeroIsFatal = False ):
65- return self .get_jdk ().run_java (
66- args , out = out , err = out , cwd = cwd , nonZeroIsFatal = nonZeroIsFatal , command_mapper_hooks = self .command_mapper_hooks )
67-
68- def generate_java_command (self , args ):
69- return self .get_jdk ().generate_java_command (self .post_process_command_line_args (args ))
70-
71- def rules (self , output , benchmarks , bmSuiteArgs ):
72- rules = super (JvmciJdkVm , self ).rules (output , benchmarks , bmSuiteArgs )
73- return rules
74-
75-
76- def add_or_replace_arg (option_key , value , vm_option_list ):
77- """
78- Determines if an option with the same key as option_key is already present in vm_option_list.
79- If so, it replaces the option value with the given one. If not, it appends the option
80- to the end of the list. It then returns the modified list.
81-
82- For example, if arg_list contains the argument '-Djdk.graal.CompilerConfig=community', and this function
83- is called with an option_key of '-Djdk.graal.CompilerConfig' and a value of 'economy', the resulting
84- argument list will contain one instance of '-Djdk.graal.CompilerConfig=economy'.
85- """
86- arg_string = option_key + '=' + value
87- idx = next ((idx for idx , arg in enumerate (vm_option_list ) if arg .startswith (option_key )), - 1 )
88- if idx == - 1 :
89- vm_option_list .append (arg_string )
90- else :
91- vm_option_list [idx ] = arg_string
92- return vm_option_list
93-
94- def build_jvmci_vm_variants (raw_name , raw_config_name , extra_args , variants , include_default = True , suite = None , priority = 0 , hosted = True ):
95- prefixes = [('' , ['-XX:+UseJVMCICompiler' ])]
96- if hosted :
97- prefixes .append (('hosted-' , ['-XX:-UseJVMCICompiler' ]))
98- for prefix , args in prefixes :
99- extended_raw_config_name = prefix + raw_config_name
100- extended_extra_args = extra_args + args
101- if include_default :
102- mx_benchmark .add_java_vm (
103- JvmciJdkVm (raw_name , extended_raw_config_name , extended_extra_args ), suite , priority )
104- for variant in variants :
105- compiler_config = None
106- if len (variant ) == 2 :
107- var_name , var_args = variant
108- var_priority = priority
109- elif len (variant ) == 3 :
110- var_name , var_args , var_priority = variant
111- elif len (variant ) == 4 :
112- var_name , var_args , var_priority , compiler_config = variant
113- else :
114- raise TypeError ("unexpected tuple size for jvmci variant {} (size must be <= 4)" .format (variant ))
115-
116- variant_args = extended_extra_args + var_args
117- if compiler_config is not None :
118- variant_args = add_or_replace_arg ('-Djdk.graal.CompilerConfiguration' , compiler_config , variant_args )
119-
120- mx_benchmark .add_java_vm (
121- JvmciJdkVm (raw_name , extended_raw_config_name + '-' + var_name , variant_args ), suite , var_priority )
122-
12340
12441_graal_variants = [
12542 ('no-tiered-comp' , ['-XX:-TieredCompilation' ], 0 ),
@@ -143,7 +60,7 @@ def build_jvmci_vm_variants(raw_name, raw_config_name, extra_args, variants, inc
14360 ('avx2' , ['-XX:UseAVX=2' ], 11 ),
14461 ('avx3' , ['-XX:UseAVX=3' ], 11 ),
14562]
146- build_jvmci_vm_variants ('server' , 'graal-core' , ['-server' , '-XX:+EnableJVMCI' , '-Djdk.graal.CompilerConfiguration=community' , '-Djvmci.Compiler=graal' ], _graal_variants , suite = _suite , priority = 15 )
63+ mx_sdk_benchmark . build_jvmci_vm_variants ('server' , 'graal-core' , ['-server' , '-XX:+EnableJVMCI' , '-Djdk.graal.CompilerConfiguration=community' , '-Djvmci.Compiler=graal' ], _graal_variants , suite = _suite , priority = 15 )
14764
14865# On 64 bit systems -client is not supported. Nevertheless, when running with -server, we can
14966# force the VM to just compile code with C1 but not with C2 by adding option -XX:TieredStopAtLevel=1.
0 commit comments