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