@@ -464,6 +464,10 @@ class TruffleGateTags:
464
464
truffle_jvm = ['truffle-jvm' ]
465
465
truffle_native = ['truffle-native' ]
466
466
truffle_native_quickbuild = ['truffle-native-quickbuild' ]
467
+ truffle_native_memory_fencing = ['truffle-native-memory-fencing' ]
468
+ truffle_native_memory_fencing_quickbuild = ['truffle-native-memory-fencing-quickbuild' ]
469
+ truffle_native_libcmusl_static = ['truffle-native-libcmusl-static' ]
470
+ truffle_native_libcmusl_static_quickbuild = ['truffle-native-libcmusl-static-quickbuild' ]
467
471
468
472
def _truffle_gate_runner (args , tasks ):
469
473
jdk = mx .get_jdk (tag = mx .DEFAULT_JDK_TAG )
@@ -516,20 +520,60 @@ def gate_truffle_jvm(tasks):
516
520
if t :
517
521
sl_jvm_gate_tests (additional_jvm_args )
518
522
523
+
524
+ def _native_image_supports_option (option ):
525
+ native_image = _native_image (mx .get_jdk (tag = 'graalvm' ))
526
+ out = mx .LinesOutputCapture ()
527
+ mx .run ([native_image , '--expert-options-all' ], out = out )
528
+ for line in out .lines :
529
+ if option in line :
530
+ return True
531
+ return False
532
+
533
+
519
534
def gate_truffle_native (tasks , quickbuild = False ):
520
535
tag = TruffleGateTags .truffle_native_quickbuild if quickbuild else TruffleGateTags .truffle_native
521
536
name_suffix = ' with quickbuild' if quickbuild else ''
537
+
522
538
with Task ('Truffle SL Native Fallback' + name_suffix , tasks , tags = tag ) as t :
523
539
if t :
524
540
sl_native_fallback_gate_tests (quickbuild )
541
+
525
542
with Task ('Truffle SL Native Optimized' + name_suffix , tasks , tags = tag ) as t :
526
543
if t :
527
544
sl_native_optimized_gate_tests (quickbuild )
545
+
528
546
with Task ('Truffle API Native Tests' + name_suffix , tasks , tags = tag ) as t :
529
547
if t :
548
+ truffle_native_context_preinitialization_tests (quickbuild )
549
+ # Test that the static object model can deal with non-long aligned byte array base offsets (GR-43403)
550
+ if _native_image_supports_option ('OptionalIdentityHashCodes' ):
551
+ truffle_native_context_preinitialization_tests (quickbuild , [
552
+ '-H:+UnlockExperimentalVMOptions' ,
553
+ '-H:-OptionalIdentityHashCodes' ,
554
+ '-H:-UnlockExperimentalVMOptions'
555
+ ])
530
556
truffle_native_unit_tests_gate (True , quickbuild )
531
557
truffle_native_unit_tests_gate (False , quickbuild )
532
558
559
+ tag = TruffleGateTags .truffle_native_memory_fencing_quickbuild if quickbuild else TruffleGateTags .truffle_native_memory_fencing
560
+ with Task ('Truffle API Native Tests with MemoryMaskingAndFencing mitigation' + name_suffix , tasks , tags = tag ) as t :
561
+ if t :
562
+ if _native_image_supports_option ('MemoryMaskingAndFencing' ):
563
+ truffle_native_unit_tests_gate (True , False , [
564
+ '-H:+UnlockExperimentalVMOptions' ,
565
+ '-R:+MemoryMaskingAndFencing' ,
566
+ '-H:-UnlockExperimentalVMOptions'
567
+ ])
568
+
569
+ tag = TruffleGateTags .truffle_native_libcmusl_static_quickbuild if quickbuild else TruffleGateTags .truffle_native_libcmusl_static
570
+ with Task ('Truffle API Native Tests with static libc musl' + name_suffix , tasks , tags = tag ) as t :
571
+ if t :
572
+ truffle_native_unit_tests_gate (True , False , [
573
+ "--libc=musl" ,
574
+ "--static"
575
+ ])
576
+
533
577
# Run with:
534
578
# mx -p ../vm --env ce build
535
579
# export JAVA_HOME=`mx -p ../vm --env ce --quiet --no-warning graalvm-home`
@@ -834,7 +878,21 @@ def sl_native_fallback_gate_tests(quick_build=False):
834
878
_sl_native_fallback_gate_tests (force_cp = True , quick_build = quick_build )
835
879
836
880
837
- def truffle_native_unit_tests_gate (use_optimized_runtime = True , quick_build = False ):
881
+ def truffle_native_context_preinitialization_tests (quick_build = False , build_args = None ):
882
+ # ContextPreInitializationNativeImageTest can only run with its own image.
883
+ # See class javadoc for details.
884
+ # Context pre-initialization is supported only in optimized runtime.
885
+ # See TruffleFeature for details.
886
+ use_build_args = build_args if build_args else []
887
+ if quick_build :
888
+ use_build_args = use_build_args + ['-Ob' ]
889
+ native_truffle_unittest (['com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest' ] + ['--build-args' ] + use_build_args )
890
+
891
+
892
+ def truffle_native_unit_tests_gate (use_optimized_runtime = True , quick_build = False , build_args = None ):
893
+ build_args = build_args if build_args else []
894
+ is_libc_musl = '--libc=musl' in build_args
895
+ is_static = '--static' in build_args
838
896
if use_optimized_runtime :
839
897
build_truffle_runtime_args = []
840
898
run_truffle_runtime_args = []
@@ -846,20 +904,18 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
846
904
else :
847
905
build_optimize_args = []
848
906
849
- # ContextPreInitializationNativeImageTest can only run with its own image.
850
- # See class javadoc for details.
851
- # Context pre-initialization is supported only in optimized runtime.
852
- # See TruffleFeature for details.
853
- if use_optimized_runtime :
854
- native_truffle_unittest (['com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest' ] +
855
- ['--build-args' ] + build_optimize_args )
856
-
857
907
# Run Truffle and NFI tests
858
908
test_packages = [
859
909
'com.oracle.truffle.api.test' ,
860
910
'com.oracle.truffle.api.staticobject.test' ,
861
- 'com.oracle.truffle.nfi .test' ,
911
+ 'com.oracle.truffle.sandbox.enterprise .test' ,
862
912
]
913
+ if not is_static :
914
+ # static executable does not support dynamic library loading required by NFI tests
915
+ test_packages += [
916
+ 'com.oracle.truffle.nfi.test' ,
917
+ ]
918
+
863
919
excluded_tests = [
864
920
'com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest' , # runs in its own image
865
921
'com.oracle.truffle.api.test.profiles.*' , # GR-52260
@@ -872,7 +928,7 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
872
928
excluded_tests = excluded_tests + [
873
929
'com.oracle.truffle.api.test.TruffleSafepointTest' # GR-44492
874
930
]
875
- build_args = build_optimize_args + build_truffle_runtime_args + [
931
+ build_args = build_args + build_optimize_args + build_truffle_runtime_args + [
876
932
'-R:MaxHeapSize=2g' ,
877
933
'-H:MaxRuntimeCompileMethods=5000' ,
878
934
'--enable-url-protocols=http,jar' ,
@@ -881,7 +937,7 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
881
937
'--add-exports=org.graalvm.truffle/com.oracle.truffle.api.impl.asm=ALL-UNNAMED' ,
882
938
'--enable-native-access=org.graalvm.truffle' ,
883
939
]
884
- run_args = run_truffle_runtime_args + [
940
+ run_args = run_truffle_runtime_args + ([ '-Xss1m' ] if is_libc_musl else []) + [
885
941
mx_subst .path_substitutions .substitute ('-Dnative.test.path=<path:truffle:TRUFFLE_TEST_NATIVE>' ),
886
942
]
887
943
exclude_args = list (itertools .chain (* [('--exclude-class' , item ) for item in excluded_tests ]))
0 commit comments