@@ -573,20 +573,16 @@ def _probe_jvmci_info(jdk, attribute_name):
573
573
sink = lambda x : x
574
574
mx .run ([jdk .java , '-XX:+UnlockExperimentalVMOptions' , '-XX:+PrintFlagsFinal' , '-version' ], out = out , err = sink )
575
575
enableJVMCI = False
576
- enableJVMCIProduct = False
577
576
jvmciThreadsPerNativeLibraryRuntime = None
578
577
for line in out .lines :
579
578
if 'EnableJVMCI' in line and 'true' in line :
580
579
enableJVMCI = True
581
- if 'EnableJVMCIProduct' in line :
582
- enableJVMCIProduct = True
583
580
if 'JVMCIThreadsPerNativeLibraryRuntime' in line :
584
581
m = re .search (r'JVMCIThreadsPerNativeLibraryRuntime *= *(\d+)' , line )
585
582
if not m :
586
583
mx .abort (f'Could not extract value of JVMCIThreadsPerNativeLibraryRuntime from "{ line } "' )
587
584
jvmciThreadsPerNativeLibraryRuntime = int (m .group (1 ))
588
585
setattr (jdk , '.enables_jvmci_by_default' , enableJVMCI )
589
- setattr (jdk , '.supports_enablejvmciproduct' , enableJVMCIProduct )
590
586
setattr (jdk , '.jvmciThreadsPerNativeLibraryRuntime' , jvmciThreadsPerNativeLibraryRuntime )
591
587
return getattr (jdk , attribute_name )
592
588
@@ -596,13 +592,6 @@ def jdk_enables_jvmci_by_default(jdk):
596
592
"""
597
593
return _probe_jvmci_info (jdk , '.enables_jvmci_by_default' )
598
594
599
- def jdk_supports_enablejvmciproduct (jdk ):
600
- """
601
- Determines if the jdk supports flag -XX:+EnableJVMCIProduct which isn't the case
602
- for some OpenJDK 11u distros.
603
- """
604
- return _probe_jvmci_info (jdk , '.supports_enablejvmciproduct' )
605
-
606
595
def get_JVMCIThreadsPerNativeLibraryRuntime (jdk ):
607
596
"""
608
597
Gets the value of the flag -XX:JVMCIThreadsPerNativeLibraryRuntime.
@@ -611,50 +600,6 @@ def get_JVMCIThreadsPerNativeLibraryRuntime(jdk):
611
600
"""
612
601
return _probe_jvmci_info (jdk , '.jvmciThreadsPerNativeLibraryRuntime' )
613
602
614
- def _probe_jlink_info (jdk , attribute_name ):
615
- """
616
- Determines if the jlink executable in `jdk` supports various options such
617
- as those added by JDK-8232080 and JDK-8237467.
618
- """
619
- if not hasattr (jdk , '.supports_JDK_8232080' ):
620
- output = mx .OutputCapture ()
621
- jlink_exe = jdk .javac .replace ('javac' , 'jlink' )
622
- mx .run ([jlink_exe , '--list-plugins' ], out = output )
623
- setattr (jdk , '.supports_JDK_8232080' , '--add-options=' in output .data or '--add-options ' in output .data )
624
- setattr (jdk , '.supports_save_jlink_argfiles' , '--save-jlink-argfiles=' in output .data or '--save-jlink-argfiles ' in output .data )
625
- setattr (jdk , '.supports_copy_files' , '--copy-files=' in output .data or '--copy-files ' in output .data )
626
- return getattr (jdk , attribute_name )
627
-
628
- def jlink_supports_8232080 (jdk ):
629
- """
630
- Determines if the jlink executable in `jdk` supports ``--add-options`` and
631
- ``--vendor-[bug-url|vm-bug-url|version]`` added by JDK-8232080.
632
- """
633
- return _probe_jlink_info (jdk , '.supports_JDK_8232080' )
634
-
635
- def jlink_has_save_jlink_argfiles (jdk ):
636
- """
637
- Determines if the jlink executable in `jdk` supports ``--save-jlink-argfiles``.
638
- """
639
- return _probe_jlink_info (jdk , '.supports_save_jlink_argfiles' )
640
-
641
- def _jdk_omits_warning_for_jlink_set_ThreadPriorityPolicy (jdk ): # pylint: disable=invalid-name
642
- """
643
- Determines if the `jdk` suppresses a warning about ThreadPriorityPolicy when it
644
- is non-zero if the value is set from the jimage.
645
- https://bugs.openjdk.java.net/browse/JDK-8235908.
646
- """
647
- if not hasattr (jdk , '.omits_ThreadPriorityPolicy_warning' ):
648
- out = mx .OutputCapture ()
649
- sink = lambda x : x
650
- tmpdir = tempfile .mkdtemp (prefix = 'jdk_omits_warning_for_jlink_set_ThreadPriorityPolicy' )
651
- jlink_exe = jdk .javac .replace ('javac' , 'jlink' )
652
- mx .run ([jlink_exe , '--add-options=-XX:ThreadPriorityPolicy=1' , '--output=' + join (tmpdir , 'jdk' ), '--add-modules=java.base' ])
653
- mx .run ([mx .exe_suffix (join (tmpdir , 'jdk' , 'bin' , 'java' )), '-version' ], out = sink , err = out )
654
- shutil .rmtree (tmpdir )
655
- setattr (jdk , '.omits_ThreadPriorityPolicy_warning' , '-XX:ThreadPriorityPolicy=1 may require system level permission' not in out .data )
656
- return getattr (jdk , '.omits_ThreadPriorityPolicy_warning' )
657
-
658
603
def _read_java_base_hashes (jdk ):
659
604
"""
660
605
Read the hashes stored in the ``java.base`` module of `jdk`.
@@ -808,65 +753,56 @@ def _get_image_vm_options(jdk, use_upgrade_module_path, modules, synthetic_modul
808
753
:return list: the list of VM options to cook into the image
809
754
"""
810
755
vm_options = []
811
- if jlink_supports_8232080 (jdk ):
812
- if mx .get_env ('CONTINUOUS_INTEGRATION' , None ) == 'true' :
813
- is_gate = mx .get_env ('BUILD_TARGET' , None ) == 'gate'
814
- is_bench = 'bench-' in mx .get_env ('BUILD_NAME' , '' )
815
- if is_gate or is_bench :
816
- # For gate and benchmark jobs, we want to know about each compilation failure
817
- # but only exit the VM on systemic compilation failure for gate jobs.
818
- vm_options .append ('-Djdk.graal.CompilationFailureAction=Diagnose' )
819
- mx .log ('Adding -Djdk.graal.CompilationFailureAction=Diagnose VM option to image' )
820
- if is_gate :
821
- mx .log ('Adding -Djdk.graal.SystemicCompilationFailureRate=-1 VM option to image' )
822
- vm_options .append ('-Djdk.graal.SystemicCompilationFailureRate=-1' )
823
-
824
- if use_upgrade_module_path or _jdk_omits_warning_for_jlink_set_ThreadPriorityPolicy (jdk ):
825
- vm_options .append ('-XX:ThreadPriorityPolicy=1' )
826
- else :
827
- mx .logv ('[Creating JDK without -XX:ThreadPriorityPolicy=1]' )
828
-
829
- if jdk_supports_enablejvmciproduct (jdk ):
830
- non_synthetic_modules = [m .name for m in modules if m not in synthetic_modules ]
831
- if default_to_jvmci or 'jdk.graal.compiler' in non_synthetic_modules :
832
- threads = get_JVMCIThreadsPerNativeLibraryRuntime (jdk )
833
- vm_options .extend (['-XX:+UnlockExperimentalVMOptions' , '-XX:+EnableJVMCIProduct' ])
834
- # -XX:+EnableJVMCI must be explicitly specified to the java launcher to add
835
- # jdk.internal.vm.ci to the root set (JDK-8345826)
836
- vm_options .append ('-XX:+EnableJVMCI' )
837
- if threads is not None and threads != 1 :
838
- vm_options .append ('-XX:JVMCIThreadsPerNativeLibraryRuntime=1' )
839
- if default_to_jvmci == 'lib' :
840
- vm_options .append ('-XX:+UseJVMCINativeLibrary' )
841
- vm_options .extend (['-XX:-UnlockExperimentalVMOptions' ])
842
- import mx_sdk_vm_impl
843
- if 'jdk.graal.compiler' in non_synthetic_modules and mx_sdk_vm_impl ._get_libgraal_component () is None :
844
- # If libgraal is absent, jargraal is used by default.
845
- # Use of jargraal requires exporting jdk.internal.misc to
846
- # Graal as it uses jdk.internal.misc.Unsafe. To avoid warnings
847
- # about unknown modules (e.g. in `-Xint` mode), the export target
848
- # modules must be explicitly added to the root set with `--add-modules`.
849
- if 'com.oracle.graal.graal_enterprise' in non_synthetic_modules :
850
- vm_options .extend ([
851
- '--add-modules=jdk.graal.compiler,com.oracle.graal.graal_enterprise' ,
852
- '--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler,com.oracle.graal.graal_enterprise'
853
- ])
854
- else :
855
- vm_options .extend ([
856
- '--add-modules=jdk.graal.compiler' ,
857
- '--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler'
858
- ])
756
+ if mx .get_env ('CONTINUOUS_INTEGRATION' , None ) == 'true' :
757
+ is_gate = mx .get_env ('BUILD_TARGET' , None ) == 'gate'
758
+ is_bench = 'bench-' in mx .get_env ('BUILD_NAME' , '' )
759
+ if is_gate or is_bench :
760
+ # For gate and benchmark jobs, we want to know about each compilation failure
761
+ # but only exit the VM on systemic compilation failure for gate jobs.
762
+ vm_options .append ('-Djdk.graal.CompilationFailureAction=Diagnose' )
763
+ mx .log ('Adding -Djdk.graal.CompilationFailureAction=Diagnose VM option to image' )
764
+ if is_gate :
765
+ mx .log ('Adding -Djdk.graal.SystemicCompilationFailureRate=-1 VM option to image' )
766
+ vm_options .append ('-Djdk.graal.SystemicCompilationFailureRate=-1' )
767
+
768
+ vm_options .append ('-XX:ThreadPriorityPolicy=1' )
769
+
770
+ non_synthetic_modules = [m .name for m in modules if m not in synthetic_modules ]
771
+ if default_to_jvmci or 'jdk.graal.compiler' in non_synthetic_modules :
772
+ threads = get_JVMCIThreadsPerNativeLibraryRuntime (jdk )
773
+ vm_options .extend (['-XX:+UnlockExperimentalVMOptions' , '-XX:+EnableJVMCIProduct' ])
774
+ # -XX:+EnableJVMCI must be explicitly specified to the java launcher to add
775
+ # jdk.internal.vm.ci to the root set (JDK-8345826)
776
+ vm_options .append ('-XX:+EnableJVMCI' )
777
+ if threads is not None and threads != 1 :
778
+ vm_options .append ('-XX:JVMCIThreadsPerNativeLibraryRuntime=1' )
779
+ if default_to_jvmci == 'lib' :
780
+ vm_options .append ('-XX:+UseJVMCINativeLibrary' )
781
+ vm_options .extend (['-XX:-UnlockExperimentalVMOptions' ])
782
+ import mx_sdk_vm_impl
783
+ if 'jdk.graal.compiler' in non_synthetic_modules and mx_sdk_vm_impl ._get_libgraal_component () is None :
784
+ # If libgraal is absent, jargraal is used by default.
785
+ # Use of jargraal requires exporting jdk.internal.misc to
786
+ # Graal as it uses jdk.internal.misc.Unsafe. To avoid warnings
787
+ # about unknown modules (e.g. in `-Xint` mode), the export target
788
+ # modules must be explicitly added to the root set with `--add-modules`.
789
+ if 'com.oracle.graal.graal_enterprise' in non_synthetic_modules :
790
+ vm_options .extend ([
791
+ '--add-modules=jdk.graal.compiler,com.oracle.graal.graal_enterprise' ,
792
+ '--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler,com.oracle.graal.graal_enterprise'
793
+ ])
859
794
else :
860
- # Don't default to using JVMCI as JIT unless Graal is being updated in the image.
861
- # This avoids unexpected issues with using the out-of-date Graal compiler in
862
- # the JDK itself.
863
- vm_options .extend (['-XX:+UnlockExperimentalVMOptions' , '-XX:+EnableJVMCIProduct' , '-XX:-UseJVMCICompiler' , '-XX:-UnlockExperimentalVMOptions' ])
864
- else :
865
- mx .logv ('[Creating JDK without -XX:+EnableJVMCIProduct]' )
866
- if modules and use_upgrade_module_path :
867
- vm_options .append ('--upgrade-module-path=' + os .pathsep .join ((synthetic_modules .get (m , m .jarpath ) for m in modules )))
868
- elif use_upgrade_module_path :
869
- mx .abort ('Cannot create an image with an --upgrade-module-path setting since jlink does not support the --add-options flag' )
795
+ vm_options .extend ([
796
+ '--add-modules=jdk.graal.compiler' ,
797
+ '--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler'
798
+ ])
799
+ else :
800
+ # Don't default to using JVMCI as JIT unless Graal is being updated in the image.
801
+ # This avoids unexpected issues with using the out-of-date Graal compiler in
802
+ # the JDK itself.
803
+ vm_options .extend (['-XX:+UnlockExperimentalVMOptions' , '-XX:+EnableJVMCIProduct' , '-XX:-UseJVMCICompiler' , '-XX:-UnlockExperimentalVMOptions' ])
804
+ if modules and use_upgrade_module_path :
805
+ vm_options .append ('--upgrade-module-path=' + os .pathsep .join ((synthetic_modules .get (m , m .jarpath ) for m in modules )))
870
806
return vm_options
871
807
872
808
def _copy_src_zip (from_jdk , to_jdk , extra_modules , extra_modules_predicate ):
@@ -967,9 +903,8 @@ def jlink_new_jdk(jdk, dst_jdk_dir, module_dists, ignore_dists,
967
903
if not isdir (jmods_dir ):
968
904
mx .abort ('Cannot derive a new JDK from ' + jdk .home + ' since ' + jmods_dir + ' is missing or is not a directory' )
969
905
970
- # Exclude jdk.aot due to GR-10545 and JDK-8255616
971
906
# Exclude graal in case it is included in the base JDK
972
- jdk_modules = {jmd .name : jmd for jmd in jdk .get_modules () if jmd . name != 'jdk.aot' and not jmd .name .startswith ('jdk.graal.compiler' )}
907
+ jdk_modules = {jmd .name : jmd for jmd in jdk .get_modules () if not jmd .name .startswith ('jdk.graal.compiler' )}
973
908
modules = [as_java_module (dist , jdk ) for dist in module_dists ]
974
909
module_names = frozenset ((m .name for m in modules ))
975
910
all_module_names = frozenset (list (jdk_modules .keys ())) | module_names
@@ -1118,7 +1053,7 @@ def get_jmod_path_with_specified_module_info(self, m):
1118
1053
jlink .append (f'--add-options={ " " .join (vm_options )} ' )
1119
1054
jlink_persist .append (f'--add-options="{ " " .join (vm_options )} "' )
1120
1055
1121
- if jlink_supports_8232080 ( jdk ) and vendor_info is not None :
1056
+ if vendor_info is not None :
1122
1057
for name , value in vendor_info .items ():
1123
1058
jlink .append (f'--{ name } ={ value } ' )
1124
1059
jlink_persist .append (f'--{ name } ="{ value } "' )
@@ -1127,11 +1062,10 @@ def get_jmod_path_with_specified_module_info(self, m):
1127
1062
if isfile (release_file ):
1128
1063
jlink .append (f'--release-info={ release_file } ' )
1129
1064
1130
- if jlink_has_save_jlink_argfiles (jdk ):
1131
- jlink_persist_argfile = join (build_dir , 'jlink.persist.options' )
1132
- with open (jlink_persist_argfile , 'w' ) as fp :
1133
- fp .write ('\n ' .join (jlink_persist ))
1134
- jlink .append (f'--save-jlink-argfiles={ jlink_persist_argfile } ' )
1065
+ jlink_persist_argfile = join (build_dir , 'jlink.persist.options' )
1066
+ with open (jlink_persist_argfile , 'w' ) as fp :
1067
+ fp .write ('\n ' .join (jlink_persist ))
1068
+ jlink .append (f'--save-jlink-argfiles={ jlink_persist_argfile } ' )
1135
1069
1136
1070
if exists (dst_jdk_dir ):
1137
1071
if use_upgrade_module_path and _vm_options_match (vm_options , vm_options_path ):
0 commit comments