diff --git a/truffle/ci/ci.jsonnet b/truffle/ci/ci.jsonnet index 62b035b16045..3c616d3a8d47 100644 --- a/truffle/ci/ci.jsonnet +++ b/truffle/ci/ci.jsonnet @@ -8,20 +8,21 @@ local darwin_amd64 = common.darwin_amd64, local darwin_aarch64 = common.darwin_aarch64, local linux_amd64 = common.linux_amd64, + local linux_aarch64 = common.linux_aarch64, local windows_amd64 = common.windows_amd64, + local winDevKit(jdk) = + devkits[ + if jdk.jdk_version == 21 + then "windows-jdk21" + else "windows-jdkLatest" + ], + local truffle_common = { setup+: [ ["cd", "./truffle"], ], - targets: ["gate"], - timelimit: "30:00", - }, - - local guard = { - guard+: { - includes+: ["/sdk/**", "/truffle/**", "**.jsonnet"] + top_level_ci, - } + notify_groups:: ["truffle"], }, local bench_common = { @@ -35,33 +36,8 @@ ] }, - local gate_lite(target) = truffle_common + { - name: target + '-truffle-lite-oraclejdk-' + self.jdk_name + '-' + self.os + '-' + self.arch, - run: [ - ["mx", "build"], - ["mx", "unittest", "--verbose"], - ], - targets: [target], - }, - - local sigtest = truffle_common + { - name: 'gate-truffle-sigtest-' + self.jdk_name, - run: [ - ["mx", "build"], - ["mx", "sigtest", "--check", (if self.jdk_version == 21 then "all" else "bin")], - ], - }, - - local graalVMCELatest = common.labsjdkLatest + common.deps.svm + { - mx_build_graalvm_cmd: ["mx", "-p", "../vm", "--env", "ce", "--native-images=lib:jvmcicompiler"], - run+: [ - self.mx_build_graalvm_cmd + ["build"], - ["set-export", "JAVA_HOME", self.mx_build_graalvm_cmd + ["--quiet", "--no-warning", "graalvm-home"]] - ] - }, - local simple_tool_maven_project_gate = truffle_common + { - name: 'gate-external-mvn-simpletool-' + self.jdk_name, + name: self.name_prefix + 'truffle-simpletool-maven-' + self.jdk_name + '-' + self.os + '-' + self.arch, packages+: { maven: "==3.3.9" }, @@ -80,7 +56,7 @@ }, local simple_language_maven_project_gate = truffle_common + { - name: 'gate-external-mvn-simplelanguage-' + self.jdk_name, + name: self.name_prefix + 'truffle-simplelanguage-maven-' + self.jdk_name + '-' + self.os + '-' + self.arch, packages+: { maven: "==3.3.9", ruby: "==3.0.2", @@ -103,146 +79,172 @@ ], }, - local truffle_jvm_gate = truffle_common + { + local truffle_common_gate = truffle_common + common.deps.eclipse + common.deps.jdt + common.deps.spotbugs { + components+: ["truffle"], + }, + + # this is only valid for gates that depend only on truffle files + # do not use for latest GraalVM builds + local guard = { + guard+: { + includes+: ["/sdk/**", "/truffle/**", "**.jsonnet"] + top_level_ci, + } + }, + + local truffle_style_gate = truffle_common_gate + guard + { + name: self.name_prefix + 'truffle-style-' + self.truffle_jdk_name + '-' + self.os + '-' + self.arch, run+: [ - ['mx', '--no-jlinking', 'gate', '--no-warning-as-error', '--tags', 'build,truffle-jvm'], + ["mx", "--strict-compliance", "gate", "--strict-mode", "--tag", "style,fullbuild,sigtest"], ], - notify_groups: ["truffle"], - components+: ["truffle"], - timelimit: '1:15:00', - name: 'gate-truffle-ce-jvm-' + self.jdk_name + '-linux-amd64', }, - # runs only truffle native unittests - local truffle_native_unittest_gate = truffle_common + { - gate_tag_suffix: '', + local truffle_test_full_gate = truffle_common_gate + guard + { + name: self.name_prefix + 'truffle-full-test-' + self.truffle_jdk_name + '-' + self.os + '-' + self.arch, run+: [ - ['mx', '--no-jlinking', 'gate', '--no-warning-as-error', '--tags', 'build,unittest-native' + self.gate_tag_suffix], + ["mx", "--strict-compliance", "gate", "--strict-mode", "--tag", "style,fullbuild,fulltest"] + ], + }, + local truffle_test_lite_gate= truffle_common_gate + guard + { + name: self.name_prefix + 'truffle-lite-test-' + self.truffle_jdk_name + '-' + self.os + '-' + self.arch, + run+: [ + ["mx", "--strict-compliance", "gate", "--strict-mode", "--tag", "build,test"], ], - notify_groups: ["truffle"], - components+: ["truffle"], - timelimit: '1:00:00', - name: 'gate-truffle-ce-native-unittest' + self.gate_tag_suffix + '-jvm-' + self.jdk_name + '-' + self.os + '-' + self.arch, }, - # runs native SL tests and truffle native unittests - local truffle_native_gate = truffle_common + { - gate_tag_suffix: '', + local truffle_test_super_lite_gate = truffle_common_gate + guard + { + name: self.name_prefix + 'truffle-super-lite-test-' + self.truffle_jdk_name + '-' + self.os + '-' + self.arch, run+: [ - ['mx', '--no-jlinking', 'gate', '--no-warning-as-error', '--tags', 'build,truffle-native' + self.gate_tag_suffix], + ["mx", "build"], + ["mx", "unittest", "--verbose"], ], - notify_groups: ["truffle"], - components+: ["truffle"], - timelimit: '1:30:00', - name: 'gate-truffle-ce-native' + self.gate_tag_suffix + '-jvm-' + self.jdk_name + '-' + self.os + '-' + self.arch, }, - local truffle_gate = truffle_common + common.deps.eclipse + common.deps.jdt + common.deps.spotbugs { - name: 'gate-truffle-oraclejdk-' + self.jdk_name + '-' + self.os + '-' + self.arch, - # The `fulltest` tag includes all Truffle test gate tasks except those that require GraalVM. - run: [["mx", "--strict-compliance", "gate", "--strict-mode", "--tag"] + (if (self.os == 'windows') then ["style:0:6,fullbuild,fulltest"] else ["style,fullbuild,fulltest"])], - environment+: if self.os == 'windows' then { - ECLIPSE_EXE: "$ECLIPSE\\eclipse.exe", - } else {}, + local truffle_coverage = truffle_common + common.deps.eclipse + common.deps.jdt + guard + { + name: self.name_prefix + 'truffle-coverage-' + self.truffle_jdk_name + '-' + self.os + '-' + self.arch, + run+: [ + ["mx", "--strict-compliance", "gate", "--strict-mode", "--jacoco-relativize-paths", "--jacoco-omit-src-gen", "--jacocout", "coverage", "--jacoco-format", "lcov", "--tags", "build,fulltest"], + ], + teardown+: [ + ["mx", "sversions", "--print-repositories", "--json", "|", "coverage-uploader.py", "--associated-repos", "-"], + ], + timelimit: "45:00", }, - local truffle_weekly = common.weekly + {notify_groups:: ["truffle"]}, + local jmh_benchmark = bench_common + { + name: self.name_prefix + 'truffle-jmh-' + self.truffle_jdk_name + '-' + self.os + '-' + self.arch, + notify_groups:: ["truffle_bench"], + run+: [ + ["mx", "--kill-with-sigquit", "benchmark", "--results-file", "${BENCH_RESULTS_FILE_PATH}", "truffle:*", "--", "--", "org.graalvm.truffle.benchmark"], + ], + timelimit: "3:00:00", + teardown: [ + ["bench-uploader.py", "${BENCH_RESULTS_FILE_PATH}"], + ], + }, + + local jmh_benchmark_test = bench_common + guard + { + name: self.name_prefix + 'truffle-test-benchmarks-' + self.truffle_jdk_name + '-' + self.os + '-' + self.arch, + run+: [ + ["mx", "benchmark", "truffle:*", "--", "--jvm", "server", "--jvm-config", "graal-core", "--", "org.graalvm.truffle.benchmark", "-f", "1", "-wi", "1", "-w", "1", "-i", "1", "-r", "1"], + ], + }, + + local tier1 = common.tier1 + { + name_prefix: "gate-", + timelimit: "0:30:00" + }, + local tier2 = common.tier2 + { + name_prefix: "gate-", + timelimit: "01:00:00" + }, + local tier3 = common.tier3 + { + name_prefix: "gate-", + timelimit: "01:15:00" + }, + local daily = common.daily + { + name_prefix: "daily-", + timelimit: "04:00:00" + }, + local weekly = common.weekly + { + name_prefix: "weekly-", + timelimit: "04:00:00" + }, + local bench = common.weekly + { + name_prefix: "bench-", + timelimit: "04:00:00" + }, + + local jdk_21_oracle = common.oraclejdk21 + {truffle_jdk_name: "oraclejdk-21"}, + local jdk_latest_oracle = common.oraclejdkLatest + {truffle_jdk_name: "oraclejdk-latest"}, + local jdk_latest_labs = common.labsjdkLatestCE+ {truffle_jdk_name: "labsjdk-latest"}, + + local jdk_latest_graalvm_ce = jdk_latest_labs + common.deps.svm + { + truffle_jdk_name: "graalvm-ce-latest", + mx_build_graalvm_cmd: ["mx", "-p", "../vm", "--env", "ce", "--native-images=lib:jvmcicompiler"], + run+: [ + self.mx_build_graalvm_cmd + ["build", "--force-javac"], + ["set-export", "JAVA_HOME", self.mx_build_graalvm_cmd + ["--quiet", "--no-warning", "graalvm-home"]] + ] + }, + + local test_jdks = [jdk_latest_oracle, jdk_21_oracle], + local graalvm_jdks = [jdk_latest_graalvm_ce], + + local forEach(arr, fn) = std.flattenArrays([fn(x) for x in arr]), local _builds = std.flattenArrays([ + + # Regular Truffle gates + [linux_amd64 + tier1 + jdk_latest_oracle + truffle_style_gate], + + forEach(test_jdks, function(jdk) [ - linux_amd64 + jdk + sigtest + guard, - darwin_amd64 + jdk + truffle_weekly + gate_lite("daily") + guard, - darwin_aarch64 + jdk + truffle_weekly + gate_lite("gate") + guard, - ] for jdk in [common.oraclejdk21, common.oraclejdkLatest] - ]) + - [ - # The simple_language_maven_project_gate uses native-image, so we must run on labsjdk rather than oraclejdk - linux_amd64 + common.graalvmee21 + simple_language_maven_project_gate, - linux_amd64 + graalVMCELatest + simple_language_maven_project_gate, - # The simple_tool_maven_project_gate builds compiler, so we must run on labsjdk rather than oraclejdk because of compiler module rename - linux_amd64 + common.graalvmee21 + simple_tool_maven_project_gate, - linux_amd64 + graalVMCELatest + simple_tool_maven_project_gate, - # Truffle JVM gate - linux_amd64 + common.graalvmee21 + truffle_jvm_gate, - # GR-65191 - # linux_amd64 + common.oraclejdk24 + truffle_jvm_gate, - linux_amd64 + graalVMCELatest + truffle_jvm_gate, - # Truffle Native gate - linux_amd64 + common.graalvmee21 + truffle_native_gate, - linux_amd64 + common.graalvmee21 + truffle_native_gate + { - gate_tag_suffix: '-quickbuild' - }, - linux_amd64 + graalVMCELatest + truffle_native_gate, - windows_amd64 + graalVMCELatest + devkits["windows-jdkLatest"] + truffle_native_unittest_gate, - linux_amd64 + graalVMCELatest + truffle_native_gate + { - gate_tag_suffix: '-quickbuild' - }, - windows_amd64 + graalVMCELatest + devkits["windows-jdkLatest"] + truffle_native_unittest_gate + { - gate_tag_suffix: '-quickbuild' - }, + linux_amd64 + tier2 + jdk + truffle_test_lite_gate, + linux_amd64 + tier3 + jdk + truffle_test_full_gate, - linux_amd64 + common.oraclejdk21 + truffle_gate + guard + {timelimit: "1:30:00"}, - linux_amd64 + common.oraclejdkLatest + truffle_gate + guard + {environment+: {DISABLE_DSL_STATE_BITS_TESTS: "true"}}, + linux_aarch64 + tier3 + jdk + truffle_test_lite_gate, + darwin_aarch64 + tier3 + jdk + truffle_test_lite_gate, + windows_amd64 + tier3 + jdk + truffle_test_lite_gate + winDevKit(jdk), - truffle_common + linux_amd64 + common.oraclejdkLatest + guard { - name: "gate-truffle-javadoc-" + self.jdk_name, - run: [ - ["mx", "build"], - ["mx", "javadoc"], - ], - }, + # we do have very few resources for Darwin AMD64 so only run weekly + darwin_amd64 + weekly + jdk + truffle_test_lite_gate, + ] + ), - truffle_common + linux_amd64 + common.oraclejdk21 + guard { - name: "gate-truffle-slow-path-unittests", - run: [ - ["mx", "build", "-n", "-c", "-A-Atruffle.dsl.GenerateSlowPathOnly=true"], - # only those tests exercise meaningfully implemented nodes - # e.g. com.oracle.truffle.api.dsl.test uses nodes that intentionally produce - # different results from fast/slow path specializations to test their activation - ["mx", "unittest", "com.oracle.truffle.api.test.polyglot", "com.oracle.truffle.nfi.test"], - ], - }, + # SimpleLanguage Maven Integration Test + forEach(graalvm_jdks, function(jdk) + [ + linux_amd64 + tier3 + jdk + simple_language_maven_project_gate, - windows_amd64 + truffle_gate + common.oraclejdk21 + devkits["windows-jdk21"] + guard + {timelimit: "1:30:00"}, - windows_amd64 + truffle_gate + common.oraclejdkLatest + devkits["windows-jdkLatest"] + guard + {timelimit: "1:00:00", environment+: {DISABLE_DSL_STATE_BITS_TESTS: "true"}}, - - truffle_common + linux_amd64 + common.oraclejdk21 + common.deps.eclipse + common.deps.jdt + guard + { - name: "weekly-truffle-coverage-21-linux-amd64", - run: [ - ["mx", "--strict-compliance", "gate", "--strict-mode", "--jacoco-relativize-paths", "--jacoco-omit-src-gen", "--jacocout", "coverage", "--jacoco-format", "lcov", "--tags", "build,fulltest"], - ], - teardown+: [ - ["mx", "sversions", "--print-repositories", "--json", "|", "coverage-uploader.py", "--associated-repos", "-"], - ], - targets: ["weekly"], - notify_groups:: ["truffle"], - timelimit: "45:00", - }, + linux_aarch64 + weekly + jdk + simple_language_maven_project_gate, + darwin_amd64 + weekly + jdk + simple_language_maven_project_gate, + darwin_aarch64 + weekly + jdk + simple_language_maven_project_gate, - # BENCHMARKS - - bench_hw.x52 + common.labsjdkLatestCE + bench_common + { - name: "bench-truffle-jmh-linux-amd64", - notify_groups:: ["truffle_bench"], - run: [ - ["mx", "--kill-with-sigquit", "benchmark", "--results-file", "${BENCH_RESULTS_FILE_PATH}", "truffle:*", "--", "--", "com.oracle.truffle"], - ], - targets+: ["weekly"], - timelimit: "3:00:00", - teardown: [ - ["bench-uploader.py", "${BENCH_RESULTS_FILE_PATH}"], - ], - }, + # GR-68277 currently unsupported + # windows_amd64 + weekly + jdk + simple_language_maven_project_gate + winDevKit(jdk), + ] + ), - linux_amd64 + common.labsjdkLatestCE + bench_common + { - name: "gate-truffle-test-benchmarks", - run: [ - ["mx", "benchmark", "truffle:*", "--", "--jvm", "server", "--jvm-config", "graal-core", "--", "com.oracle.truffle", "-f", "1", "-wi", "1", "-w", "1", "-i", "1", "-r", "1"], - ], - targets: ["gate"], - timelimit: "30:00", - }, - ], + # SimpleTool Maven Integration Test + forEach(graalvm_jdks, function(jdk) + [ + linux_amd64 + tier3 + jdk + simple_tool_maven_project_gate, + + linux_aarch64 + weekly + jdk + simple_tool_maven_project_gate, + darwin_amd64 + weekly + jdk + simple_tool_maven_project_gate, + darwin_aarch64 + weekly + jdk + simple_tool_maven_project_gate, + + # GR-68277 currently unsupported + # windows_amd64 + weekly + jdk + simple_tool_maven_project_gate + winDevKit(jdk), + ] + ), + + # Truffle Coverage + [linux_amd64 + weekly + jdk_21_oracle + truffle_coverage], + # Truffle Benchmarks + [linux_amd64 + tier3 + jdk_latest_labs + jmh_benchmark_test], + [bench_hw.x52 + bench + jdk_latest_labs + jmh_benchmark] + ]), builds: utils.add_defined_in(_builds, std.thisFile), } diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py index 81e68eff93a3..442de76fc0a6 100644 --- a/truffle/mx.truffle/mx_truffle.py +++ b/truffle/mx.truffle/mx_truffle.py @@ -460,30 +460,33 @@ def _native_image_sl(jdk, vm_args, target_dir, use_optimized_runtime=True, use_e class TruffleGateTags: style = ['style'] - javadoc = ['javadoc'] + javadoc = ['javadoc', 'style'] sigtest = ['sigtest', 'test', 'fulltest'] truffle_test = ['truffle-test', 'test', 'fulltest'] panama_test = ['panama-test', 'test', 'fulltest'] string_test = ['string-test', 'test', 'fulltest'] dsl_max_state_bit_test = ['dsl-max-state-bit-test', 'fulltest'] - parser_test = ['parser-test', 'test', 'fulltest'] + generate_slow_path_test = ['fulltest'] + parser_test = ['parser-test', 'fulltest'] truffle_jvm = ['truffle-jvm'] - sl_native = ['sl-native', 'truffle-native'] - sl_native_quickbuild = ['sl-native-quickbuild', 'truffle-native-quickbuild'] - unittest_native = ['unittest-native', 'truffle-native'] - unittest_native_quickbuild = ['unittest-native-quickbuild', 'truffle-native-quickbuild'] + truffle_jvm_lite = ['truffle-jvm-lite', 'truffle-jvm'] + truffle_native = ['truffle-native'] + truffle_native_lite = ['truffle-native-lite', 'truffle-native'] + # LibC Musl tests need special setup so we can't run them in truffle-native truffle_native_libcmusl_static = ['truffle-native-libcmusl-static'] - truffle_native_libcmusl_static_quickbuild = ['truffle-native-libcmusl-static-quickbuild'] def _truffle_gate_runner(args, tasks): jdk = mx.get_jdk(tag=mx.DEFAULT_JDK_TAG) - if jdk.javaCompliance < '9': - with Task('Truffle Javadoc', tasks, tags=TruffleGateTags.javadoc) as t: - if t: javadoc([]) + with Task('Truffle Javadoc', tasks, tags=TruffleGateTags.javadoc) as t: + if t: javadoc([]) with Task('File name length check', tasks, tags=TruffleGateTags.style) as t: if t: check_filename_length([]) with Task('Truffle Signature Tests', tasks, tags=TruffleGateTags.sigtest) as t: - if t: sigtest(['--check', 'binary']) + if t: + if jdk.javaCompliance == '21': + sigtest(['--check', 'all']) + else: + sigtest(['--check', 'binary']) with Task('Truffle UnitTests', tasks, tags=TruffleGateTags.truffle_test) as t: if t: unittest(['--suite', 'truffle', '--enable-timing', '--verbose', '--max-class-failures=25']) @@ -498,60 +501,81 @@ def _truffle_gate_runner(args, tasks): with Task('Truffle DSL max state bit tests', tasks, tags=TruffleGateTags.dsl_max_state_bit_test) as t: if t: _truffle_gate_state_bitwidth_tests() + with Task('Truffle DSL Generate Slow Path Tests', tasks, tags=TruffleGateTags.generate_slow_path_test) as t: + if t: + _truffle_generate_slow_path_tests() with Task('Validate parsers', tasks, tags=TruffleGateTags.parser_test) as t: if t: validate_parsers() gate_truffle_jvm(tasks) gate_truffle_native(tasks) - gate_truffle_native(tasks, quickbuild=True) def gate_truffle_jvm(tasks): + jdk = mx.get_jdk(tag='default') if mx_sdk.GraalVMJDKConfig.is_libgraal_jdk(mx.get_jdk(tag='default').home): additional_jvm_args = mx_sdk.GraalVMJDKConfig.libgraal_additional_vm_args else: additional_jvm_args = [] # GR-62632: Debug VM exception translation failure additional_jvm_args += ['-Djdk.internal.vm.TranslatedException.debug=true'] - with Task('Truffle ModulePath Unit Tests Optimized', tasks, tags=TruffleGateTags.truffle_jvm) as t: + + with Task('Truffle ModulePath Unit Tests Optimized', tasks, tags=TruffleGateTags.truffle_jvm_lite) as t: if t: truffle_jvm_module_path_optimized_unit_tests_gate(additional_jvm_args) + with Task('Truffle ModulePath Unit Tests Fallback', tasks, tags=TruffleGateTags.truffle_jvm) as t: if t: truffle_jvm_module_path_fallback_unit_tests_gate(additional_jvm_args) + with Task('Truffle ClassPath Unit Tests Optimized', tasks, tags=TruffleGateTags.truffle_jvm) as t: if t: truffle_jvm_class_path_optimized_unit_tests_gate(additional_jvm_args) + with Task('Truffle ClassPath Unit Tests Fallback', tasks, tags=TruffleGateTags.truffle_jvm) as t: if t: truffle_jvm_class_path_fallback_unit_tests_gate(additional_jvm_args) + + with Task('Truffle SL JVM Lite', tasks, tags=TruffleGateTags.truffle_jvm) as t: + if t: + _sl_jvm_gate_tests(jdk, additional_jvm_args, force_cp=False, compile_immediately=False) + with Task('Truffle SL JVM', tasks, tags=TruffleGateTags.truffle_jvm) as t: if t: - sl_jvm_gate_tests(additional_jvm_args) + supports_optimization = mx_sdk.GraalVMJDKConfig.is_graalvm(jdk.home) or mx_sdk.GraalVMJDKConfig.is_libgraal_jdk(jdk.home) + _sl_jvm_gate_tests(jdk, additional_jvm_args, force_cp=True, compile_immediately=supports_optimization) + _sl_jvm_gate_tests(jdk, additional_jvm_args, force_cp=False, compile_immediately=supports_optimization) + + +def gate_truffle_native(tasks): + with Task('Truffle SL Native ModulePath', tasks, tags=TruffleGateTags.truffle_native) as t: + if t: + _sl_native_fallback_gate_tests(force_cp=False) + _sl_native_optimized_gate_tests(force_cp=False) + with Task('Truffle SL Native ClassPath', tasks, tags=TruffleGateTags.truffle_native) as t: + if t: + _sl_native_fallback_gate_tests(force_cp=True) + _sl_native_optimized_gate_tests(force_cp=True) -def gate_truffle_native(tasks, quickbuild=False): - tag = TruffleGateTags.sl_native_quickbuild if quickbuild else TruffleGateTags.sl_native - name_suffix = ' with quickbuild' if quickbuild else '' + with Task('Truffle Native Unit Preinitialization Tests', tasks, tags=TruffleGateTags.truffle_native) as t: + if t: + truffle_native_context_preinitialization_tests() - with Task('Truffle SL Native Fallback' + name_suffix, tasks, tags=tag) as t: + with Task('Truffle Native Unit Tests Optimized', tasks, tags=TruffleGateTags.truffle_native_lite) as t: if t: - sl_native_fallback_gate_tests(quickbuild) + truffle_native_unit_tests_gate(use_optimized_runtime=True) - with Task('Truffle SL Native Optimized' + name_suffix, tasks, tags=tag) as t: + with Task('Truffle Native Unit Tests Fallback', tasks, tags=TruffleGateTags.truffle_native) as t: if t: - sl_native_optimized_gate_tests(quickbuild) + truffle_native_unit_tests_gate(use_optimized_runtime=False) - tag = TruffleGateTags.unittest_native_quickbuild if quickbuild else TruffleGateTags.unittest_native - with Task('Truffle API Native Tests' + name_suffix, tasks, tags=tag) as t: + with Task('Truffle Native Unit Tests Quick Build', tasks, tags=TruffleGateTags.truffle_native) as t: if t: - truffle_native_context_preinitialization_tests(quickbuild) - truffle_native_unit_tests_gate(True, quickbuild) - truffle_native_unit_tests_gate(False, quickbuild) + truffle_native_unit_tests_gate(use_optimized_runtime=True, build_args=['-Ob']) - tag = TruffleGateTags.truffle_native_libcmusl_static_quickbuild if quickbuild else TruffleGateTags.truffle_native_libcmusl_static - with Task('Truffle API Native Tests with static libc musl' + name_suffix, tasks, tags=tag) as t: + with Task('Truffle API Native Tests with static libc musl', tasks, tags=TruffleGateTags.truffle_native_libcmusl_static) as t: if t: - truffle_native_unit_tests_gate(True, False, [ + truffle_native_unit_tests_gate(True, [ "--libc=musl", "--static" ]) @@ -759,21 +783,9 @@ def _allow_runtime_reflection(for_types): mx.warn(f'The native Truffle unit test has failed, preserving the working directory at {tmp} for further investigation.') -# Run with: -# mx -p ../vm --env ce build -# export JAVA_HOME=`mx -p ../vm --env ce --quiet --no-warning graalvm-home` -# mx build -# mx gate -o -t "Truffle SL JVM" -def sl_jvm_gate_tests(additional_vm_args): - jdk = mx.get_jdk(tag='default') - supports_optimization = mx_sdk.GraalVMJDKConfig.is_graalvm(jdk.home) or mx_sdk.GraalVMJDKConfig.is_libgraal_jdk(jdk.home) - _sl_jvm_gate_tests(jdk, additional_vm_args, force_cp=False, supports_optimization=supports_optimization) - _sl_jvm_gate_tests(jdk, additional_vm_args, force_cp=True, supports_optimization=supports_optimization) - - -def _sl_jvm_gate_tests(jdk, vm_args, force_cp=False, supports_optimization=True): +def _sl_jvm_gate_tests(jdk, vm_args, force_cp=False, compile_immediately=True): default_args = [] - if not supports_optimization: + if not compile_immediately: default_args += ['--engine.WarnInterpreterOnly=false'] def run_jvm_fallback(test_file): @@ -792,7 +804,7 @@ def run_jvmci_disabled(test_file): mx.log(f'Run SL JVM JVMCI disabled on {jdk.home} force_cp={force_cp}') _run_sl_tests(run_jvmci_disabled) - if supports_optimization: + if compile_immediately: mx.log(f'Run SL JVM Optimized Immediately Test on {jdk.home} force_cp={force_cp}') _run_sl_tests(run_jvm_optimized_immediately) @@ -810,7 +822,7 @@ def run_jvm_no_enterprise_jvmci_disabled(test_file): mx.log(f'Run SL JVM Optimized Test No Truffle Enterprise on {jdk.home} force_cp={force_cp}') _run_sl_tests(run_jvm_no_enterprise_optimized) - if supports_optimization: + if compile_immediately: mx.log(f'Run SL JVM Optimized Immediately Test No Truffle Enterprise on {jdk.home} force_cp={force_cp}') _run_sl_tests(run_jvm_no_enterprise_optimized_immediately) @@ -818,17 +830,10 @@ def run_jvm_no_enterprise_jvmci_disabled(test_file): _run_sl_tests(run_jvm_no_enterprise_jvmci_disabled) -# Run in VM suite with: -# mx --env ce --native-images=. build -# mx --env ce --native-images=. gate -o -t "Truffle SL Native Optimized" -def sl_native_optimized_gate_tests(quick_build=False): - _sl_native_optimized_gate_tests(force_cp=False, quick_build=quick_build) - _sl_native_optimized_gate_tests(force_cp=True, quick_build=quick_build) - -def _sl_native_optimized_gate_tests(force_cp, quick_build): +def _sl_native_optimized_gate_tests(force_cp): target_dir = tempfile.mkdtemp() jdk = mx.get_jdk(tag='graalvm') - vm_args = ['-Ob'] if quick_build else [] + vm_args = [] image = _native_image_sl(jdk, vm_args, target_dir, use_optimized_runtime=True, use_enterprise=True) def run_native_optimized(test_file): @@ -862,27 +867,16 @@ def run_no_enterprise_native_optimized_immediately(test_file): shutil.rmtree(target_dir) - -# Run in VM suite with: -# mx --env ce --native-images=. build -# mx --env ce --native-images=. gate -o -t "Truffle SL Native Fallback" -def sl_native_fallback_gate_tests(quick_build=False): - _sl_native_fallback_gate_tests(force_cp=False, quick_build=quick_build) - _sl_native_fallback_gate_tests(force_cp=True, quick_build=quick_build) - - -def truffle_native_context_preinitialization_tests(quick_build=False, build_args=None): +def truffle_native_context_preinitialization_tests(build_args=None): # ContextPreInitializationNativeImageTest can only run with its own image. # See class javadoc for details. # Context pre-initialization is supported only in optimized runtime. # See TruffleFeature for details. use_build_args = build_args if build_args else [] - if quick_build: - use_build_args = use_build_args + ['-Ob'] native_truffle_unittest(['com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest'] + ['--build-args'] + use_build_args) -def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False, build_args=None): +def truffle_native_unit_tests_gate(use_optimized_runtime=True, build_args=None): build_args = build_args if build_args else [] is_libc_musl = '--libc=musl' in build_args is_static = '--static' in build_args @@ -892,10 +886,7 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False else: build_truffle_runtime_args = ['-Dtruffle.UseFallbackRuntime=true'] run_truffle_runtime_args = ['-Dpolyglot.engine.WarnInterpreterOnly=false'] - if quick_build: - build_optimize_args = ['-Ob'] - else: - build_optimize_args = [] + build_optimize_args = [] # Run Truffle and NFI tests test_packages = [ @@ -916,11 +907,8 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False 'com.oracle.truffle.api.test.nodes.*', # GR-52262 'com.oracle.truffle.api.test.host.*', # GR-52263 'com.oracle.truffle.api.test.interop.*', # GR-52264 + 'com.oracle.truffle.api.test.TruffleSafepointTest' # GR-44492 ] - if quick_build: - excluded_tests = excluded_tests + [ - 'com.oracle.truffle.api.test.TruffleSafepointTest' # GR-44492 - ] build_args = build_args + build_optimize_args + build_truffle_runtime_args + [ '-R:MaxHeapSize=2g', '-H:MaxRuntimeCompileMethods=5000', @@ -937,10 +925,10 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False native_truffle_unittest(test_packages + ['--build-args'] + build_args + ['--run-args'] + run_args + exclude_args) -def _sl_native_fallback_gate_tests(force_cp, quick_build): +def _sl_native_fallback_gate_tests(force_cp): target_dir = tempfile.mkdtemp() jdk = mx.get_jdk(tag='graalvm') - vm_args = ['-Ob'] if quick_build else [] + vm_args = [] image = _native_image_sl(jdk, vm_args, target_dir, use_optimized_runtime=False, force_cp=force_cp) def run_native_fallback(test_file): @@ -1000,6 +988,20 @@ def _truffle_gate_state_bitwidth_tests(): mx.log(' mx build {0}'.format(" ".join(build_args))) mx.log(' mx unittest {0}'.format(" ".join(unittest_args))) +def _truffle_generate_slow_path_tests(): + build_args = ['-f', '-p', '--dependencies', 'TRUFFLE_TEST', '--force-javac', + '-A-Atruffle.dsl.GenerateSlowPathOnly=true'] + + unittest_args = ['--suite', 'truffle', '--enable-timing', '--max-class-failures=25', + 'com.oracle.truffle.api.test.polyglot', 'com.oracle.truffle.nfi.test'] + try: + mx.build(build_args) + unittest(unittest_args) + finally: + mx.log('Completed Truffle DSL Generate Slow Path Tests. Reproduce with:') + mx.log(' mx build {0}'.format(" ".join(build_args))) + mx.log(' mx unittest {0}'.format(" ".join(unittest_args))) + mx_gate.add_gate_runner(_suite, _truffle_gate_runner) mx.update_commands(_suite, { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index 0386fe9eeae4..b248ac9153b7 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -1186,7 +1186,7 @@ public void testCacheCleanupNode() throws IllegalArgumentException, IllegalAcces private void assertInParallel(Supplier nodeFactory, ParallelObjectConsumer assertions) throws InterruptedException { final int threads = THREADS; final int threadPools = 4; - final int iterations = 1000; + final int iterations = 100; /* * We create multiple nodes and run the assertions in a loop to avoid implicit * synchronization through the synchronization primitives when running the assertions just diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/memory/ByteArraySupportTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/memory/ByteArraySupportTest.java index 1ebb2e204401..3e18dcb20579 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/memory/ByteArraySupportTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/memory/ByteArraySupportTest.java @@ -44,6 +44,7 @@ import java.nio.charset.StandardCharsets; import org.junit.Assert; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -55,6 +56,11 @@ public class ByteArraySupportTest { @BeforeClass public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); + + // combination currently broken GR-68403 + Assume.assumeFalse(TruffleTestAssumptions.isAOT() && TruffleTestAssumptions.isAarch64()); + + TruffleTestAssumptions.assumeNotAOT(); } @Test diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/ThreadInitializationAndDisposalTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/ThreadInitializationAndDisposalTest.java index 2e7463003e0e..c81840afff95 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/ThreadInitializationAndDisposalTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/ThreadInitializationAndDisposalTest.java @@ -40,10 +40,10 @@ */ package com.oracle.truffle.api.test.polyglot; +import java.lang.ref.Reference; import java.time.Duration; import java.util.concurrent.atomic.AtomicLong; -import com.oracle.truffle.api.test.ThreadUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Engine; import org.junit.Assert; @@ -56,6 +56,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.test.ThreadUtils; import com.oracle.truffle.api.test.common.AbstractExecutableTestLanguage; import com.oracle.truffle.api.test.common.TestUtils; @@ -176,6 +177,9 @@ public void testDeadThreadDisposed() throws InterruptedException { Assert.assertEquals(threadId.get() + "," + mainThreadId, context.getBindings(DeadThreadDisposedTestLanguage.ID).getMember("initialized").asString()); Assert.assertEquals(String.valueOf(threadId.get()), context.getBindings(DeadThreadDisposedTestLanguage.ID).getMember("finalized").asString()); Assert.assertEquals(String.valueOf(threadId.get()), context.getBindings(DeadThreadDisposedTestLanguage.ID).getMember("disposed").asString()); + + // the thread needs to stay alive during the test + Reference.reachabilityFence(t); } } } diff --git a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TruffleTestAssumptions.java b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TruffleTestAssumptions.java index 9ce970e8dce6..9efcb5f82667 100644 --- a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TruffleTestAssumptions.java +++ b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TruffleTestAssumptions.java @@ -119,6 +119,15 @@ public static boolean isExternalIsolate() { return externalIsolate; } + public static boolean isLinux() { + return System.getProperty("os.name").toLowerCase().equals("linux"); + } + + public static boolean isAarch64() { + String osArch = System.getProperty("os.arch").toLowerCase(); + return osArch.equals("aarch64") || osArch.equals("arm64"); // some JVMs use arm64 + } + public static void assumeAOT() { Assume.assumeTrue(aot); } diff --git a/truffle/src/org.graalvm.truffle.benchmark/src/org/graalvm/truffle/benchmark/tstring/JsJsonBenchmark.java b/truffle/src/org.graalvm.truffle.benchmark/src/org/graalvm/truffle/benchmark/tstring/JsJsonBenchmark.java deleted file mode 100644 index 5292afc33801..000000000000 --- a/truffle/src/org.graalvm.truffle.benchmark/src/org/graalvm/truffle/benchmark/tstring/JsJsonBenchmark.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package org.graalvm.truffle.benchmark.tstring; - -import org.graalvm.polyglot.Context; -import org.graalvm.polyglot.Value; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; - -public class JsJsonBenchmark extends TStringBenchmarkBase { - - @State(Scope.Benchmark) - public static class BenchState { - Context context; - final Value jsonParse; - - public BenchState() { - context = Context.newBuilder("js").build(); - context.enter(); - context.eval("js", """ - const OBJECT_SIZE = 500; - const obj = {}; - - for (let i = 0; i < OBJECT_SIZE; i++) { - obj["double_key" + i] = Math.random(); - obj["str_key" + i] = '#'.repeat(50); - }; - - function jsonParseStringify() { - return JSON.parse(JSON.stringify(obj)); - }; - """); - jsonParse = context.parse("js", "jsonParseStringify()"); - } - - @TearDown - public void tearDown() { - context.leave(); - context.close(); - } - } - - @Benchmark - public Value jsonParse(BenchState state) { - return state.jsonParse.execute(); - } - -}