From a20b485fd568a47e93ce557b28a8b039306aef55 Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Wed, 8 Jan 2025 00:38:49 +0000 Subject: [PATCH 01/12] Adding CI to master --- .github/scripts/Make.user | 2 + .github/scripts/ci-build.sh | 48 ++++++++++++ .github/scripts/ci-checkout.sh | 12 +++ .github/scripts/ci-ffi.sh | 15 ++++ .github/scripts/ci-setup.sh | 9 +++ .github/scripts/ci-style.sh | 13 ++++ .github/scripts/ci-test-LinearAlgebra.sh | 16 ++++ .github/scripts/ci-test-gc-core.sh | 29 +++++++ .github/scripts/ci-test-other.sh | 38 ++++++++++ .github/scripts/ci-test-patching.sh | 70 +++++++++++++++++ .github/scripts/ci-test-stdlib.sh | 75 ++++++++++++++++++ .github/scripts/ci-test.sh | 18 +++++ .github/scripts/common.sh | 34 +++++++++ .github/scripts/hello_world.jl | 1 + .github/workflows/binding-tests.yml | 96 ++++++++++++++++++++++++ .github/workflows/ci.yml | 26 +++++++ 16 files changed, 502 insertions(+) create mode 100644 .github/scripts/Make.user create mode 100644 .github/scripts/ci-build.sh create mode 100644 .github/scripts/ci-checkout.sh create mode 100644 .github/scripts/ci-ffi.sh create mode 100644 .github/scripts/ci-setup.sh create mode 100644 .github/scripts/ci-style.sh create mode 100644 .github/scripts/ci-test-LinearAlgebra.sh create mode 100644 .github/scripts/ci-test-gc-core.sh create mode 100644 .github/scripts/ci-test-other.sh create mode 100644 .github/scripts/ci-test-patching.sh create mode 100644 .github/scripts/ci-test-stdlib.sh create mode 100644 .github/scripts/ci-test.sh create mode 100644 .github/scripts/common.sh create mode 100644 .github/scripts/hello_world.jl create mode 100644 .github/workflows/binding-tests.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/scripts/Make.user b/.github/scripts/Make.user new file mode 100644 index 00000000..234e2fea --- /dev/null +++ b/.github/scripts/Make.user @@ -0,0 +1,2 @@ +FORCE_ASSERTIONS=1 +LLVM_ASSERTIONS=1 diff --git a/.github/scripts/ci-build.sh b/.github/scripts/ci-build.sh new file mode 100644 index 00000000..b12d79f1 --- /dev/null +++ b/.github/scripts/ci-build.sh @@ -0,0 +1,48 @@ +set -xe + +. $(dirname "$0")/common.sh + +# Need a build_type argument +if [ $# -eq 0 ] + then + echo "No arguments supplied" + exit 1 +fi +# debug or release +build_type=$1 +# plan to use +plan=$2 +# moving vs non-moving +is_moving=$3 + +# helloworld.jl +HELLO_WORLD_JL=$BINDING_PATH/.github/scripts/hello_world.jl + +# build MMTk +build_args="" +if [ "$build_type" == "release" ]; then + build_args=$build_args" --release" +fi + +plan_feature=${plan,,} +moving_feature=${is_moving,,} + +if [ "$is_moving" == "moving" ]; then + MOVING=1 +else + MOVING=0 +fi + +cd $MMTK_JULIA_DIR + +MMTK_MOVING=$MOVING make $build_type + +cd $JULIA_PATH + +# Clean first +make cleanall +# Build +cp $BINDING_PATH/.github/scripts/Make.user $JULIA_PATH/ +MMTK_PLAN=$plan MMTK_BUILD=$build_type make +# Run hello world +$JULIA_PATH/julia $HELLO_WORLD_JL diff --git a/.github/scripts/ci-checkout.sh b/.github/scripts/ci-checkout.sh new file mode 100644 index 00000000..5b42aacb --- /dev/null +++ b/.github/scripts/ci-checkout.sh @@ -0,0 +1,12 @@ +set -ex + +. $(dirname "$0")/common.sh + +# We may later allow setting up a specific version of Julia using comments +# in the PR, but for now we just use the latest master from JuliaLang +JULIA_URL=https://github.com/JuliaLang/julia.git +JULIA_VERSION=master + +rm -rf $JULIA_PATH +git clone $JULIA_URL $JULIA_PATH +git -C $JULIA_PATH checkout $JULIA_VERSION diff --git a/.github/scripts/ci-ffi.sh b/.github/scripts/ci-ffi.sh new file mode 100644 index 00000000..51c2ec18 --- /dev/null +++ b/.github/scripts/ci-ffi.sh @@ -0,0 +1,15 @@ +set -ex + +. $(dirname "$0")/common.sh + +pushd $MMTK_JULIA_DIR + +make regen-bindgen-ffi + +if ! git diff --exit-code mmtk/julia_types.rs; then + echo "Rust FFI bindings in \`julia_types.rs\` are outdated. Run \`make regen-bindgen-ffi\` from the mmtk-julia directory and make sure to include the updated file in the pull request." + exit 1 +fi + +popd + diff --git a/.github/scripts/ci-setup.sh b/.github/scripts/ci-setup.sh new file mode 100644 index 00000000..593a085d --- /dev/null +++ b/.github/scripts/ci-setup.sh @@ -0,0 +1,9 @@ +set -xe + +. $(dirname "$0")/common.sh + +rustup toolchain install $RUSTUP_TOOLCHAIN +rustup target add i686-unknown-linux-gnu --toolchain $RUSTUP_TOOLCHAIN +rustup component add clippy --toolchain $RUSTUP_TOOLCHAIN +rustup component add rustfmt --toolchain $RUSTUP_TOOLCHAIN +rustup override set $RUSTUP_TOOLCHAIN diff --git a/.github/scripts/ci-style.sh b/.github/scripts/ci-style.sh new file mode 100644 index 00000000..02f2a1eb --- /dev/null +++ b/.github/scripts/ci-style.sh @@ -0,0 +1,13 @@ +set -xe + +. $(dirname "$0")/common.sh + +export RUSTFLAGS="-D warnings" + +pushd $BINDING_PATH/mmtk + +cargo clippy +cargo clippy --release + +cargo fmt -- --check +popd diff --git a/.github/scripts/ci-test-LinearAlgebra.sh b/.github/scripts/ci-test-LinearAlgebra.sh new file mode 100644 index 00000000..5d099dd3 --- /dev/null +++ b/.github/scripts/ci-test-LinearAlgebra.sh @@ -0,0 +1,16 @@ +# Running LinearAlgebra as a separate item +# Given it takes on average more than 2.5h to run + +set -e + +. $(dirname "$0")/common.sh + +export MMTK_MAX_HSIZE_G=8 +total_mem=$(free -m | awk '/^Mem:/ {print $2}') +mem_threshold=512 # use 0.5Gb as a threshold for the max rss based on the total free memory +total_mem_restricted=$((total_mem- mem_threshold)) +num_workers=2 +export JULIA_TEST_MAXRSS_MB=$((total_mem_restricted/ num_workers)) + +echo "-> Run single threaded" +ci_run_jl_test "LinearAlgebra" 2 diff --git a/.github/scripts/ci-test-gc-core.sh b/.github/scripts/ci-test-gc-core.sh new file mode 100644 index 00000000..ce472017 --- /dev/null +++ b/.github/scripts/ci-test-gc-core.sh @@ -0,0 +1,29 @@ +set -e + +# run tests that are more specific to the GC +# this list was built intuitively based on tests that +# call the gc manually, have finalizers, have multiple threads, etc. + +. $(dirname "$0")/common.sh + +declare -a test_names=( + "gc" # Julia's GC specific testset + "threads" # Tests for multithreading (with some GC interaction) + "cmdlineargs" # Has tests that spawn other processes + "compiler" # Some tests for allocation, compiled code checks + "misc" # set of miscelaneous tests, include finalizers, eg + "core" # should have the core of the Julia code + "dict" # tests for weak references +) + +for i in "${test_names[@]}" +do + # echo "Token: '$i'" + test=`sed 's/\"\(.*\)\"/\1/' <<< $i` + if [[ ! -z "$test" ]]; then + echo $test + + echo "-> Run" + ci_run_jl_test $test + fi +done diff --git a/.github/scripts/ci-test-other.sh b/.github/scripts/ci-test-other.sh new file mode 100644 index 00000000..09e04d88 --- /dev/null +++ b/.github/scripts/ci-test-other.sh @@ -0,0 +1,38 @@ +set -xe + +. $(dirname "$0")/common.sh + +# Get all the tests +CHOOSE_TESTS_JL_PATH=$JULIA_PATH/test/choosetests.jl +CHOOSE_TESTS_JL_CONTENT=`cat $CHOOSE_TESTS_JL_PATH` + +REGEX_PATTERN='.*const TESTNAMES = \[([^\[]*)^\].*' + +if [[ $CHOOSE_TESTS_JL_CONTENT =~ $REGEX_PATTERN ]]; then + RAW_TEST_NAMES=${BASH_REMATCH[1]} + + readarray -td, test_names <<< "$RAW_TEST_NAMES" + declare test_names + + for i in "${test_names[@]}" + do + # echo "Token: '$i'" + test=`sed 's/\"\(.*\)\"/\1/' <<< $i` + if [[ ! -z "$test" ]]; then + echo $test + + # Should we skip some tests? + # Ignore stdlib tests for now -- we run stdlib tests separately + if [[ $test =~ "stdlib" ]]; then + echo "-> Skip stdlib" + continue + fi + + echo "-> Run" + ci_run_jl_test $test + fi + done +else + echo "Cannot find TESTNAMES in $CHOOSE_TESTS_JL_PATH" + exit 1 +fi diff --git a/.github/scripts/ci-test-patching.sh b/.github/scripts/ci-test-patching.sh new file mode 100644 index 00000000..192feef1 --- /dev/null +++ b/.github/scripts/ci-test-patching.sh @@ -0,0 +1,70 @@ +set -xe + +. $(dirname "$0")/common.sh + +# The list of tests/checks that we need to skip. They are either not suitable for Julia-MMTk, or +# not supported at this moment. +# Each line is a pattern of the test to match (we add skip=true to the end of those lines), and the test file path +# * Pattern ends with $ so we won't append 'skip=true' multiple times +declare -a tests_to_skip=( + # Ignore the entire libgit2.jl -- there are too many possible network related issues to run this test + # '@test.*$' "$JULIA_PATH/usr/share/julia/stdlib/v1.8/LibGit2/test/libgit2.jl" + + # These tests check for the number of stock GC threads (which we set to 0 with mmtk) + '@test string(cpu_threads) ==' "$JULIA_PATH/test/cmdlineargs.jl" + '@test (cpu_threads == 1 ? "1" : string(div(cpu_threads, 2))) ==' "$JULIA_PATH/test/cmdlineargs.jl" + '@test read(`$exename --gcthreads=2 -e $code`, String) == "2"' "$JULIA_PATH/test/cmdlineargs.jl" + '@test read(`$exename --gcthreads=2,1 -e $code`, String) == "3"' "$JULIA_PATH/test/cmdlineargs.jl" + '@test read(`$exename -e $code`, String) == "2"' "$JULIA_PATH/test/cmdlineargs.jl" + '@test read(`$exename -e $code`, String) == "3"' "$JULIA_PATH/test/cmdlineargs.jl" + + # These tests use the heapsize hint which is not used by mmtk + '@test readchomp(`$(Base.julia_cmd()) --startup-file=no --heap-size-hint=500M' "$JULIA_PATH/test/cmdlineargs.jl" + '@test readchomp(`$(Base.julia_cmd()) --startup-file=no --heap-size-hint=10M' "$JULIA_PATH/test/cmdlineargs.jl" + '@test abs(Float64(maxmem)' "$JULIA_PATH/test/cmdlineargs.jl" + + # For some reason this fails even with the stock build + '@test n_precompiles <= expected_precompiles' "$JULIA_PATH/stdlib/REPL/test/precompilation.jl" + '@test length(targets) > 1' "$JULIA_PATH/test/precompile.jl" + + # rr might not be available in the github runner + '@test success(pipeline(setenv(`$(Base.julia_cmd()) --bug-report=rr-local' "$JULIA_PATH/test/cmdlineargs.jl" + + # These tests seem to fail because we set the number of stock GC threads to 0 + 'jl_setaffinity(1, mask, cpumasksize) == 0' "$JULIA_PATH/test/threads.jl" + 'jl_getaffinity(1, mask, cpumasksize) == 0' "$JULIA_PATH/test/threads.jl" + + # Skipping these GC tests for now (until we make sure we follow the stats as expected by the stock GC) + '@test !live_bytes_has_grown_too_much' "$JULIA_PATH/test/gc.jl" + '@test any(page_utilization .> 0)' "$JULIA_PATH/test/gc.jl" + + # Tests that check the reasons for a full sweep and are specific to stock Julia + '@test reasons\[:FULL_SWEEP_REASON_FORCED_FULL_SWEEP\] >= 1' "$JULIA_PATH/test/gc.jl" + '@test keys(reasons) == Set(Base.FULL_SWEEP_REASONS)' "$JULIA_PATH/test/gc.jl" + + # Allocation profiler tests that fail when we inline fastpath allocation + '@test length(\[a for a in prof.allocs if a.type == MyType\]) >= 1' "$JULIA_PATH/stdlib/Profile/test/allocs.jl" + '@test length(prof.allocs) >= 1' "$JULIA_PATH/stdlib/Profile/test/allocs.jl" + '@test length(filter(a->a.type <: type, profile.allocs)) >= NUM_TASKS' "$JULIA_PATH/stdlib/Profile/test/allocs.jl" + + # Test that expects information from heap snapshot which is currently not available in MMTk + '@test contains(sshot, "redact_this")' "$JULIA_PATH/stdlib/Profile/test/runtests.jl" + + # This test checks GC logging + '@test occursin("GC: pause", read(tmppath, String))' "$JULIA_PATH/test/misc.jl" + + # These tests check for the number of stock GC threads (which we set to 0 with mmtk) + '@test (cpu_threads == 1 ? "1" : string(div(cpu_threads, 2))) ==' "$JULIA_PATH/test/cmdlineargs.jl" + '@test read(`$exename --gcthreads=2 -e $code`, String) == "2"' "$JULIA_PATH/test/cmdlineargs.jl" + '@test read(`$exename -e $code`, String) == "2"' "$JULIA_PATH/test/cmdlineargs.jl" + # This seems to be a regression from upstream when we merge with upstream 43bf2c8. + # The required string int.jl does not appear in the output even if I test with the stock Julia code. + # I do not know what is wrong, but at this point, I dont want to spend time on it. + '@test occursin("int.jl", code)' "$JULIA_PATH/test/cmdlineargs.jl" +) + +for (( i=0; i < ${#tests_to_skip[@]}; i+=2 )); do + pattern=${tests_to_skip[i]} + file=${tests_to_skip[i+1]} + sed -i '/'"$pattern"'/ s/@test/@test_skip/' $file +done diff --git a/.github/scripts/ci-test-stdlib.sh b/.github/scripts/ci-test-stdlib.sh new file mode 100644 index 00000000..f2858768 --- /dev/null +++ b/.github/scripts/ci-test-stdlib.sh @@ -0,0 +1,75 @@ +# We run stdlib tests separately, as it takes long and some tests are failling. +# Julia's make file also treats stdlib special. It is reasonable that we treat them differently. + +set -e + +. $(dirname "$0")/common.sh + +# These tests seem to fail. We skip them. +declare -a tests_to_skip=( + # Test Failed at /home/runner/work/mmtk-julia/mmtk-julia/vm/julia/usr/share/julia/stdlib/v1.8/Dates/test/io.jl:45 + # Expression: repr(t) == shown + # Evaluated: "Time(0, 0, 0, 1)" == "Dates.Time(0, 0, 0, 1)" + # Seems to be an issue with their tests or runtime system: https://github.com/JuliaLang/julia/pull/29466 + "Dates" + # getnameinfo(ip"0.1.1.1") == "0.1.1.1" + # DNSError: ip"0.1.1.1", temporary failure (EAI_AGAIN) + "Sockets" + # LoadError: No active project + # See https://github.com/JuliaLang/julia/issues/50055. + # FIXME: We should run this test when the above issue is resolved. + "Pkg", + "SparseArrays" + # Running LinearAlgebra in a separate job + "LinearAlgebra" +) +# These tests need multiple workers. +declare -a tests_with_multi_workers=( + "Pkg" +) +# These tests run with a single worker +declare -a tests_with_single_worker=( + "SparseArrays", +) + +stdlib_path=$JULIA_PATH/usr/share/julia/stdlib + +# They should have one directory in the path, like v1.8. The actual libraries are under that directory. +stdlib_version_path=$(find $stdlib_path -mindepth 1 -maxdepth 1) +# Should be exactly one directory +if [ $(find $stdlib_path -mindepth 1 -maxdepth 1 | wc -l) -ne 1 ]; then + echo "Error: We expect to fine EXACTLY one directory under "$stdlib_path + echo "We found" + echo $stdlib_version_path + exit 1 +fi + +for dir in $(find $stdlib_version_path -depth -mindepth 1 -type d -o -type l) +do + # if there is a runtests.jl, we run it. + if [ -e "$dir/test/runtests.jl" ]; then + # Get the basename such as Dates/Sockets/LinearAlgebra/etc + test=$(echo "$dir" | xargs -I {} basename {}) + echo "Run stdlib tests: "$test + + # Skip some tests + if [[ "${tests_to_skip[@]}" =~ "$test" ]]; then + echo "-> Skip" + continue + fi + + if [[ "${tests_with_multi_workers[@]}" =~ "$test" ]]; then + echo "-> Run multi threaded" + ci_run_jl_test $test 2 + continue + fi + + if [[ "${tests_with_single_worker[@]}" =~ "$test" ]]; then + echo "-> Run single threaded" + ci_run_jl_test $test 1 + continue + fi + + ci_run_jl_test $test + fi +done diff --git a/.github/scripts/ci-test.sh b/.github/scripts/ci-test.sh new file mode 100644 index 00000000..24ccc26f --- /dev/null +++ b/.github/scripts/ci-test.sh @@ -0,0 +1,18 @@ +set -xe + +cur=$(realpath $(dirname "$0")) + +# Build debug - skip this. Otherwise it takes too long +# cd $cur +# ./ci-build.sh debug + +# Patch some tests to skip +. $(dirname "$0")/ci-test-patching.sh + +# Build release +cd $cur +./ci-build.sh release Immix + +# Use release build to run tests +cd $cur +./ci-test-gc-core.sh diff --git a/.github/scripts/common.sh b/.github/scripts/common.sh new file mode 100644 index 00000000..7b10c356 --- /dev/null +++ b/.github/scripts/common.sh @@ -0,0 +1,34 @@ +BINDING_PATH=$(realpath $(dirname "$0"))/../.. +export JULIA_PATH=$BINDING_PATH/vm/julia + +RUSTUP_TOOLCHAIN=`cat $BINDING_PATH/mmtk/rust-toolchain` +JULIA_TEST_ARGS='--check-bounds=yes --startup-file=no --depwarn=error' + +# Julia binding requires these +export MMTK_JULIA_DIR=$BINDING_PATH + +# Make sure we have enough heap to build Julia +export MMTK_MIN_HSIZE_G=0.5 +export MMTK_MAX_HSIZE_G=4 +# Make sure we do not get OOM killed. +total_mem=$(free -m | awk '/^Mem:/ {print $2}') +export JULIA_TEST_MAXRSS_MB=$total_mem + +ci_run_jl_test() { + test=$1 + threads=$2 + + # if no argument is given, use 2 as default + if [ -z "$threads" ]; then + threads=2 + fi + + cd $JULIA_PATH + export JULIA_CPU_THREADS=$threads + + # Directly run runtests.jl: There could be some issues with some test suites. We better just use their build script. + # $JULIA_PATH/julia $JULIA_TEST_ARGS $JULIA_PATH/test/runtests.jl --exit-on-error $test + + # Run with their build script + make test-$test +} diff --git a/.github/scripts/hello_world.jl b/.github/scripts/hello_world.jl new file mode 100644 index 00000000..f3fb71ad --- /dev/null +++ b/.github/scripts/hello_world.jl @@ -0,0 +1 @@ +println("Hello World") diff --git a/.github/workflows/binding-tests.yml b/.github/workflows/binding-tests.yml new file mode 100644 index 00000000..57235058 --- /dev/null +++ b/.github/workflows/binding-tests.yml @@ -0,0 +1,96 @@ +name: Test Julia Binding + +on: + workflow_call: + inputs: + gc_plan: + required: true + type: string + moving: + required: true + type: string + +jobs: + build-debug: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - name: Setup environments + run: | + ./.github/scripts/ci-checkout.sh + ./.github/scripts/ci-setup.sh + # removing these as they cause a conflict within bindgen + sudo rm -rf /usr/lib/llvm-14 + sudo rm -rf /usr/lib/llvm-13 + - name: Check FFI bindings + run: | + ./.github/scripts/ci-ffi.sh + - name: Build Julia (Debug) + run: | + ./.github/scripts/ci-build.sh debug ${{ inputs.gc_plan }} ${{ inputs.moving }} + - name: Style check + run: | + ./.github/scripts/ci-style.sh + + build-test-other: + runs-on: ubuntu-22.04 + timeout-minutes: 360 + steps: + - uses: actions/checkout@v2 + - name: Setup environments + run: | + ./.github/scripts/ci-checkout.sh + ./.github/scripts/ci-setup.sh + # removing these as they cause a conflict within bindgen + sudo rm -rf /usr/lib/llvm-14 + sudo rm -rf /usr/lib/llvm-13 + - name: Patching unsupported tests + run: | + ./.github/scripts/ci-test-patching.sh + - name: Build Julia (Release) + run: | + ./.github/scripts/ci-build.sh release ${{ inputs.gc_plan }} ${{ inputs.moving }} + - name: Test Julia + run: | + ./.github/scripts/ci-test-other.sh + + build-test-stdlib: + runs-on: ubuntu-22.04 + timeout-minutes: 360 + steps: + - uses: actions/checkout@v2 + - name: Setup environments + run: | + ./.github/scripts/ci-checkout.sh + ./.github/scripts/ci-setup.sh + # removing these as they cause a conflict within bindgen + sudo rm -rf /usr/lib/llvm-14 + sudo rm -rf /usr/lib/llvm-13 + - name: Patching unsupported tests + run: | + ./.github/scripts/ci-test-patching.sh + - name: Build Julia (Release) + run: | + ./.github/scripts/ci-build.sh release ${{ inputs.gc_plan }} ${{ inputs.moving }} + - name: Test Julia + run: | + ./.github/scripts/ci-test-stdlib.sh + + build-test-LinearAlgebra: + runs-on: ubuntu-22.04 + timeout-minutes: 360 + steps: + - uses: actions/checkout@v2 + - name: Setup environments + run: | + ./.github/scripts/ci-checkout.sh + ./.github/scripts/ci-setup.sh + # removing these as they cause a conflict within bindgen + sudo rm -rf /usr/lib/llvm-14 + sudo rm -rf /usr/lib/llvm-13 + - name: Build Julia (Release) + run: | + ./.github/scripts/ci-build.sh release ${{ inputs.gc_plan }} ${{ inputs.moving }} + - name: Test Julia + run: | + ./.github/scripts/ci-test-LinearAlgebra.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..79384d73 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: Test Julia Binding + +on: + pull_request: + branches: + - master + - v1.8.2\+RAI + - v1.9.2\+RAI + - dev + +concurrency: + # Cancels pending runs when a PR gets updated. + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + binding-tests: + strategy: + fail-fast: false + matrix: + gc_plan: [Immix] + moving: [Non_Moving] + uses: ./.github/workflows/binding-tests.yml + with: + gc_plan: ${{ matrix.gc_plan }} + moving: ${{ matrix.moving }} From 9c8725656bfc169bc786d160cd0d01cab22ed1fc Mon Sep 17 00:00:00 2001 From: Luis Eduardo de Souza Amorim Date: Wed, 8 Jan 2025 01:29:58 +0000 Subject: [PATCH 02/12] Adding permission --- .github/scripts/ci-build.sh | 0 .github/scripts/ci-checkout.sh | 0 .github/scripts/ci-ffi.sh | 0 .github/scripts/ci-setup.sh | 0 .github/scripts/ci-style.sh | 0 .github/scripts/ci-test-LinearAlgebra.sh | 0 .github/scripts/ci-test-gc-core.sh | 0 .github/scripts/ci-test-other.sh | 0 .github/scripts/ci-test-patching.sh | 0 .github/scripts/ci-test-stdlib.sh | 0 .github/scripts/ci-test.sh | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/scripts/ci-build.sh mode change 100644 => 100755 .github/scripts/ci-checkout.sh mode change 100644 => 100755 .github/scripts/ci-ffi.sh mode change 100644 => 100755 .github/scripts/ci-setup.sh mode change 100644 => 100755 .github/scripts/ci-style.sh mode change 100644 => 100755 .github/scripts/ci-test-LinearAlgebra.sh mode change 100644 => 100755 .github/scripts/ci-test-gc-core.sh mode change 100644 => 100755 .github/scripts/ci-test-other.sh mode change 100644 => 100755 .github/scripts/ci-test-patching.sh mode change 100644 => 100755 .github/scripts/ci-test-stdlib.sh mode change 100644 => 100755 .github/scripts/ci-test.sh diff --git a/.github/scripts/ci-build.sh b/.github/scripts/ci-build.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-checkout.sh b/.github/scripts/ci-checkout.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-ffi.sh b/.github/scripts/ci-ffi.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-setup.sh b/.github/scripts/ci-setup.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-style.sh b/.github/scripts/ci-style.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-test-LinearAlgebra.sh b/.github/scripts/ci-test-LinearAlgebra.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-test-gc-core.sh b/.github/scripts/ci-test-gc-core.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-test-other.sh b/.github/scripts/ci-test-other.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-test-patching.sh b/.github/scripts/ci-test-patching.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-test-stdlib.sh b/.github/scripts/ci-test-stdlib.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/ci-test.sh b/.github/scripts/ci-test.sh old mode 100644 new mode 100755 From 7f762771fc2bc0caa33ba0245dc18a55067493e6 Mon Sep 17 00:00:00 2001 From: Luis Eduardo de Souza Amorim Date: Wed, 8 Jan 2025 01:35:30 +0000 Subject: [PATCH 03/12] Minor --- .github/scripts/ci-ffi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/ci-ffi.sh b/.github/scripts/ci-ffi.sh index 51c2ec18..76f2c497 100755 --- a/.github/scripts/ci-ffi.sh +++ b/.github/scripts/ci-ffi.sh @@ -6,7 +6,7 @@ pushd $MMTK_JULIA_DIR make regen-bindgen-ffi -if ! git diff --exit-code mmtk/julia_types.rs; then +if ! git diff --exit-code $MMTK_JULIA_DIR/mmtk/src/julia_types.rs; then echo "Rust FFI bindings in \`julia_types.rs\` are outdated. Run \`make regen-bindgen-ffi\` from the mmtk-julia directory and make sure to include the updated file in the pull request." exit 1 fi From 8a38dab324a2a66cb87326163c93da6d0734e573 Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Wed, 8 Jan 2025 02:42:42 +0000 Subject: [PATCH 04/12] Fixing clippy issues --- mmtk/build.rs | 2 +- mmtk/src/active_plan.rs | 12 +++++----- mmtk/src/api.rs | 42 ++++++++++++++++---------------- mmtk/src/collection.rs | 6 ++--- mmtk/src/julia_finalizer.rs | 2 +- mmtk/src/julia_scanning.rs | 48 ++++++++++++++++++------------------- mmtk/src/lib.rs | 3 +++ mmtk/src/object_model.rs | 21 ++++++++-------- mmtk/src/reference_glue.rs | 2 +- mmtk/src/scanning.rs | 46 ++++++++++++++++++++--------------- 10 files changed, 96 insertions(+), 88 deletions(-) diff --git a/mmtk/build.rs b/mmtk/build.rs index 25d81b65..3871e374 100644 --- a/mmtk/build.rs +++ b/mmtk/build.rs @@ -11,7 +11,7 @@ fn main() { let mmtk_dir = match std::env::var(mmtk_dir_key) { Ok(mmtk_val) => mmtk_val, - _ => format!(".."), + _ => "..".to_string(), }; // If bindings file already exists, no need to do anything diff --git a/mmtk/src/active_plan.rs b/mmtk/src/active_plan.rs index 9c140caa..4bab9d79 100644 --- a/mmtk/src/active_plan.rs +++ b/mmtk/src/active_plan.rs @@ -18,7 +18,7 @@ pub struct JuliaMutatorIterator<'a> { impl<'a> JuliaMutatorIterator<'a> { fn new(guard: RwLockReadGuard<'a, HashMap>) -> Self { - let vec = guard.keys().map(|addr| *addr).collect(); + let vec = guard.keys().copied().collect(); Self { _guard: guard, vec, @@ -49,7 +49,7 @@ impl ActivePlan for VMActivePlan { fn is_mutator(tls: VMThread) -> bool { // FIXME have a tls field to check whether it is a mutator tls - MUTATORS.read().unwrap().keys().find(|mutator_addr| unsafe { &*mutator_addr.to_mut_ptr::>() }.mutator_tls.0 == tls).is_some() + MUTATORS.read().unwrap().keys().any(|mutator_addr| unsafe { &*mutator_addr.to_mut_ptr::>() }.mutator_tls.0 == tls) } fn mutator(_tls: VMMutatorThread) -> &'static mut Mutator { @@ -67,7 +67,7 @@ impl ActivePlan for VMActivePlan { _worker: &mut GCWorker, ) -> ObjectReference { queue.enqueue(object); - return object; + object } } @@ -80,17 +80,17 @@ pub extern "C" fn mmtk_new_mutator_iterator() -> *mut JuliaMutatorIterator<'stat } #[no_mangle] -pub extern "C" fn mmtk_get_next_mutator_tls( +pub unsafe extern "C" fn mmtk_get_next_mutator_tls( iter: *mut JuliaMutatorIterator<'static>, ) -> OpaquePointer { - match unsafe { iter.as_mut() }.unwrap().next() { + match { iter.as_mut() }.unwrap().next() { Some(m) => m.mutator_tls.0 .0, None => OpaquePointer::from_address(Address::ZERO), } } #[no_mangle] -pub extern "C" fn mmtk_close_mutator_iterator(iter: *mut JuliaMutatorIterator<'static>) { +pub unsafe extern "C" fn mmtk_close_mutator_iterator(iter: *mut JuliaMutatorIterator<'static>) { // The boxed pointer will get dropped let _to_drop = unsafe { Box::from_raw(iter) }; } diff --git a/mmtk/src/api.rs b/mmtk/src/api.rs index c5f5942c..d0d69485 100644 --- a/mmtk/src/api.rs +++ b/mmtk/src/api.rs @@ -52,27 +52,27 @@ pub extern "C" fn mmtk_gc_init( } // Set heap size - let success; - if min_heap_size != 0 { - info!( - "Setting mmtk heap size to a variable size with min-max of {}-{} (in bytes)", - min_heap_size, max_heap_size - ); - success = builder.options.gc_trigger.set( - mmtk::util::options::GCTriggerSelector::DynamicHeapSize( - min_heap_size, - max_heap_size, - ), - ); - } else { - info!( - "Setting mmtk heap size to a fixed max of {} (in bytes)", - max_heap_size - ); - success = builder.options.gc_trigger.set( - mmtk::util::options::GCTriggerSelector::FixedHeapSize(max_heap_size), - ); - } + let success = + if min_heap_size != 0 { + info!( + "Setting mmtk heap size to a variable size with min-max of {}-{} (in bytes)", + min_heap_size, max_heap_size + ); + builder.options.gc_trigger.set( + mmtk::util::options::GCTriggerSelector::DynamicHeapSize( + min_heap_size, + max_heap_size, + ), + ) + } else { + info!( + "Setting mmtk heap size to a fixed max of {} (in bytes)", + max_heap_size + ); + builder.options.gc_trigger.set( + mmtk::util::options::GCTriggerSelector::FixedHeapSize(max_heap_size), + ) + }; assert!( success, "Failed to set heap size to {}-{}", diff --git a/mmtk/src/collection.rs b/mmtk/src/collection.rs index fe5de20b..d3c7e4eb 100644 --- a/mmtk/src/collection.rs +++ b/mmtk/src/collection.rs @@ -61,7 +61,7 @@ impl Collection for VMCollection { AtomicBool::store(&BLOCK_FOR_GC, false, Ordering::SeqCst); AtomicBool::store(&WORLD_HAS_STOPPED, false, Ordering::SeqCst); - let &(_, ref cvar) = &*STW_COND.clone(); + let (_, cvar) = &*STW_COND.clone(); cvar.notify_all(); info!( @@ -109,7 +109,7 @@ impl Collection for VMCollection { } fn is_collection_enabled() -> bool { - unsafe { jl_get_gc_disable_counter() <= 0 } + unsafe { jl_get_gc_disable_counter() == 0 } } } @@ -124,7 +124,7 @@ pub fn is_current_gc_nursery() -> bool { pub extern "C" fn mmtk_block_thread_for_gc() { AtomicBool::store(&BLOCK_FOR_GC, true, Ordering::SeqCst); - let &(ref lock, ref cvar) = &*STW_COND.clone(); + let (lock, cvar) = &*STW_COND.clone(); let mut count = lock.lock().unwrap(); info!("Blocking for GC!"); diff --git a/mmtk/src/julia_finalizer.rs b/mmtk/src/julia_finalizer.rs index 16ee0221..dcae8f25 100644 --- a/mmtk/src/julia_finalizer.rs +++ b/mmtk/src/julia_finalizer.rs @@ -75,7 +75,7 @@ impl ArrayListT { // Some arraylist_t pointers used in finalizer implementation. /// ptls->finalizers: new finalizers are registered into this thread local list - fn thread_local_finalizer_list(mutator: &Mutator) -> &mut ArrayListT { + fn thread_local_finalizer_list(mutator: &mut Mutator) -> &mut ArrayListT { let list = unsafe { jl_gc_get_thread_finalizer_list(mutator.mutator_tls.0 .0) }; unsafe { &mut *list.to_mut_ptr() } } diff --git a/mmtk/src/julia_scanning.rs b/mmtk/src/julia_scanning.rs index 5c59c789..ff5c2aba 100644 --- a/mmtk/src/julia_scanning.rs +++ b/mmtk/src/julia_scanning.rs @@ -57,7 +57,7 @@ pub unsafe fn mmtk_jl_to_typeof(t: Address) -> *const jl_datatype_t { let ty = jl_small_typeof[t_raw / std::mem::size_of::
()]; return ty; } - return t.to_ptr::(); + t.to_ptr::() } const PRINT_OBJ_TYPE: bool = false; @@ -177,10 +177,10 @@ pub unsafe fn scan_julia_object>(obj: Address, clos process_slot(closure, slot); obj8_begin = obj8_begin.shift::(1); } - } else if vtag_usize == ((jl_small_typeof_tags_jl_string_tag as usize) << 4) { - if PRINT_OBJ_TYPE { - println!("scan_julia_obj {}: string\n", obj); - } + } else if vtag_usize == ((jl_small_typeof_tags_jl_string_tag as usize) << 4) + && PRINT_OBJ_TYPE + { + println!("scan_julia_obj {}: string\n", obj); } return; } else { @@ -310,9 +310,7 @@ pub unsafe fn scan_julia_object>(obj: Address, clos let layout = (*vt).layout; let npointers = (*layout).npointers; - if npointers == 0 { - return; - } else { + if npointers != 0 { if vt == jl_binding_partition_type { let bpart_ptr = obj.to_mut_ptr::(); let restriction = (*bpart_ptr).restriction._M_i; @@ -383,16 +381,16 @@ pub unsafe fn mmtk_scan_gcstack>( let copy_stack = (*ta).ctx.copy_stack_custom(); #[cfg(feature = "julia_copy_stack")] - if stkbuf != std::ptr::null_mut() && copy_stack != 0 { + if !stkbuf.is_null() && copy_stack != 0 { let stkbuf_slot = Address::from_ptr(::std::ptr::addr_of!((*ta).ctx.stkbuf)); process_slot(closure, stkbuf_slot); } let mut s = (*ta).gcstack; - let (mut offset, mut lb, mut ub) = (0 as isize, 0 as u64, u64::MAX); + let (mut offset, mut lb, mut ub) = (0_isize, 0_u64, u64::MAX); #[cfg(feature = "julia_copy_stack")] - if stkbuf != std::ptr::null_mut() && copy_stack != 0 && (*ta).ptls == std::ptr::null_mut() { + if !stkbuf.is_null() && copy_stack != 0 && (*ta).ptls.is_null() { if ((*ta).tid._M_i) < 0 { panic!("tid must be positive.") } @@ -402,10 +400,10 @@ pub unsafe fn mmtk_scan_gcstack>( offset = (*ta).ctx.stkbuf as isize - lb as isize; } - if s != std::ptr::null_mut() { + if !s.is_null() { let s_nroots_addr = ::std::ptr::addr_of!((*s).nroots); let mut nroots = read_stack(Address::from_ptr(s_nroots_addr), offset, lb, ub); - debug_assert!(nroots.as_usize() as u32 <= std::u32::MAX); + debug_assert!(nroots.as_usize() as u32 <= u32::MAX); let mut nr = nroots >> 2; loop { @@ -458,7 +456,7 @@ pub unsafe fn mmtk_scan_gcstack>( } // just call into C, since the code is cold - if (*ta).excstack != std::ptr::null_mut() { + if !(*ta).excstack.is_null() { jl_gc_scan_julia_exc_obj( Address::from_ptr(ta), Address::from_mut_ptr(closure), @@ -477,9 +475,9 @@ unsafe fn read_stack(addr: Address, offset: isize, lb: u64, ub: u64) -> Address #[inline(always)] fn get_stack_addr(addr: Address, offset: isize, lb: u64, ub: u64) -> Address { if addr.as_usize() >= lb as usize && addr.as_usize() < ub as usize { - return addr + offset; + addr + offset } else { - return addr; + addr } } @@ -532,14 +530,14 @@ pub fn mmtk_decode_restriction_value(pku: usize) -> usize { // need to apply (pku & ~0x7) to get the object to be traced // so we use (pku & 0x7) to get the offset from the object // and pass it to process_offset_slot - return pku & 0x7; + pku & 0x7 } #[cfg(not(target_pointer_width = "64"))] { // when not #ifdef _P64 we simply return pku.val // i.e., the offset is 0, since val is the first field - return 0; + 0 } } @@ -573,7 +571,7 @@ pub fn mmtk_jl_array_ndimwords(ndims: u32) -> usize { return 0; } - return (ndims - 2) as usize; + (ndims - 2) as usize } #[inline(always)] @@ -602,7 +600,7 @@ pub unsafe fn mmtk_jl_svecref(vt: *mut jl_svec_t, i: usize) -> *const jl_datatyp let svec_data = mmtk_jl_svec_data(Address::from_mut_ptr(vt)); let result_ptr = svec_data + i; let result = result_ptr.atomic_load::(Ordering::Relaxed); - ::std::mem::transmute::(result) + result as *const _jl_datatype_t } #[inline(always)] @@ -624,12 +622,12 @@ pub unsafe fn mmtk_jl_fielddesc_size(fielddesc_type: u16) -> u32 { const JL_BT_NON_PTR_ENTRY: usize = usize::MAX; -pub fn mmtk_jl_bt_is_native(bt_entry: *mut jl_bt_element_t) -> bool { +pub unsafe fn mmtk_jl_bt_is_native(bt_entry: *mut jl_bt_element_t) -> bool { let entry = unsafe { (*bt_entry).__bindgen_anon_1.uintptr }; entry != JL_BT_NON_PTR_ENTRY } -pub fn mmtk_jl_bt_entry_size(bt_entry: *mut jl_bt_element_t) -> usize { +pub unsafe fn mmtk_jl_bt_entry_size(bt_entry: *mut jl_bt_element_t) -> usize { if mmtk_jl_bt_is_native(bt_entry) { 1 } else { @@ -637,19 +635,19 @@ pub fn mmtk_jl_bt_entry_size(bt_entry: *mut jl_bt_element_t) -> usize { } } -pub fn mmtk_jl_bt_num_jlvals(bt_entry: *mut jl_bt_element_t) -> usize { +pub unsafe fn mmtk_jl_bt_num_jlvals(bt_entry: *mut jl_bt_element_t) -> usize { debug_assert!(!mmtk_jl_bt_is_native(bt_entry)); let entry = unsafe { (*bt_entry.add(1)).__bindgen_anon_1.uintptr }; entry & 0x7 } -pub fn mmtk_jl_bt_num_uintvals(bt_entry: *mut jl_bt_element_t) -> usize { +pub unsafe fn mmtk_jl_bt_num_uintvals(bt_entry: *mut jl_bt_element_t) -> usize { debug_assert!(!mmtk_jl_bt_is_native(bt_entry)); let entry = unsafe { (*bt_entry.add(1)).__bindgen_anon_1.uintptr }; (entry >> 3) & 0x7 } -pub fn mmtk_jl_bt_entry_jlvalue(bt_entry: *mut jl_bt_element_t, i: usize) -> ObjectReference { +pub unsafe fn mmtk_jl_bt_entry_jlvalue(bt_entry: *mut jl_bt_element_t, i: usize) -> ObjectReference { let entry = unsafe { (*bt_entry.add(2 + i)).__bindgen_anon_1.jlvalue }; debug_assert!(!entry.is_null()); unsafe { ObjectReference::from_raw_address_unchecked(Address::from_mut_ptr(entry)) } diff --git a/mmtk/src/lib.rs b/mmtk/src/lib.rs index 50931fd1..cf7f40d5 100644 --- a/mmtk/src/lib.rs +++ b/mmtk/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::missing_safety_doc)] + extern crate libc; extern crate log; extern crate mmtk; @@ -31,6 +33,7 @@ pub mod julia_scanning; #[allow(improper_ctypes_definitions)] #[allow(non_upper_case_globals)] #[allow(non_snake_case)] +#[allow(clippy::all)] pub mod julia_types; #[derive(Default)] diff --git a/mmtk/src/object_model.rs b/mmtk/src/object_model.rs index 21c48d3f..86a7b332 100644 --- a/mmtk/src/object_model.rs +++ b/mmtk/src/object_model.rs @@ -109,7 +109,7 @@ impl ObjectModel for VMObjectModel { Self::LOCAL_FORWARDING_BITS_SPEC.store_atomic::( from, - 0b10 as u8, // BEING_FORWARDED + 0b10_u8, // BEING_FORWARDED None, Ordering::SeqCst, ); @@ -126,8 +126,7 @@ impl ObjectModel for VMObjectModel { // not being called by objects in LOS debug_assert!(!is_object_in_los(&object)); - let obj_size = unsafe { get_so_object_size(object) }; - obj_size + unsafe { get_so_object_size(object) } } fn get_size_when_copied(_object: ObjectReference) -> usize { @@ -152,12 +151,11 @@ impl ObjectModel for VMObjectModel { #[inline(always)] fn ref_to_object_start(object: ObjectReference) -> Address { - let res = if is_object_in_los(&object) { + if is_object_in_los(&object) { object.to_raw_address() - 48 } else { unsafe { get_object_start_ref(object) } - }; - res + } } #[inline(always)] @@ -178,6 +176,7 @@ pub fn is_object_in_los(object: &ObjectReference) -> bool { } #[inline(always)] +/// This function uses mutable static variables and requires unsafe annotation pub unsafe fn get_so_object_size(object: ObjectReference) -> usize { let obj_address = object.to_raw_address(); let mut vtag = mmtk_jl_typetagof(obj_address); @@ -199,7 +198,7 @@ pub unsafe fn get_so_object_size(object: ObjectReference) -> usize { vtag = Address::from_usize(vtag_usize); } else if vtag_usize < ((jl_small_typeof_tags_jl_max_tags as usize) << 4) { if vtag_usize == ((jl_small_typeof_tags_jl_simplevector_tag as usize) << 4) { - let length = (*obj_address.to_ptr::()).length as usize; + let length = (*obj_address.to_ptr::()).length; let dtsz = length * std::mem::size_of::
() + std::mem::size_of::(); debug_assert!( @@ -209,7 +208,7 @@ pub unsafe fn get_so_object_size(object: ObjectReference) -> usize { ); return llt_align(dtsz + JULIA_HEADER_SIZE, 16); - } else if vtag_usize == ((jl_small_typeof_tags_jl_module_tag as usize) << 4) as usize { + } else if vtag_usize == ((jl_small_typeof_tags_jl_module_tag as usize) << 4) { let dtsz = std::mem::size_of::(); debug_assert!( dtsz + JULIA_HEADER_SIZE <= 2032, @@ -276,9 +275,9 @@ pub unsafe fn get_so_object_size(object: ObjectReference) -> usize { let how = jl_gc_genericmemory_how(obj_address); let res = if how == 0 { let layout = (*(mmtk_jl_typetagof(obj_address).to_ptr::())).layout; - let mut sz = (*layout).size as usize * (*m).length as usize; + let mut sz = (*layout).size as usize * (*m).length; if (*layout).flags.arrayelem_isunion() != 0 { - sz += (*m).length as usize; + sz += (*m).length; } let dtsz = llt_align(std::mem::size_of::(), 16); @@ -301,7 +300,7 @@ pub unsafe fn get_so_object_size(object: ObjectReference) -> usize { dtsz + JULIA_HEADER_SIZE ); - return llt_align(dtsz + JULIA_HEADER_SIZE, 16); + llt_align(dtsz + JULIA_HEADER_SIZE, 16) } #[inline(always)] diff --git a/mmtk/src/reference_glue.rs b/mmtk/src/reference_glue.rs index 9805803a..d7c65306 100644 --- a/mmtk/src/reference_glue.rs +++ b/mmtk/src/reference_glue.rs @@ -63,7 +63,7 @@ impl ReferenceGlue for VMReferenceGlue { fn get_referent(object: ObjectReference) -> Option { let value = Self::load_referent_raw(object); if value == unsafe { jl_nothing } { - return None; + None } else { debug_assert!( !value.is_null(), diff --git a/mmtk/src/scanning.rs b/mmtk/src/scanning.rs index 2d4466b7..a82209ed 100644 --- a/mmtk/src/scanning.rs +++ b/mmtk/src/scanning.rs @@ -107,27 +107,29 @@ impl Scanning for VMScanning { // Scan backtrace buffer: See gc_queue_bt_buf in gc.c let mut i = 0; while i < ptls.bt_size { - let bt_entry = unsafe { ptls.bt_data.add(i) }; - let bt_entry_size = mmtk_jl_bt_entry_size(bt_entry); - if mmtk_jl_bt_is_native(bt_entry) { + unsafe { + let bt_entry = ptls.bt_data.add(i); + let bt_entry_size = mmtk_jl_bt_entry_size(bt_entry); + if mmtk_jl_bt_is_native(bt_entry) { + i += bt_entry_size; + continue; + } + let njlvals = mmtk_jl_bt_num_jlvals(bt_entry); + for j in 0..njlvals { + let bt_entry_value = mmtk_jl_bt_entry_jlvalue(bt_entry, j); + + // captures wrong root nodes before creating the work + debug_assert!( + bt_entry_value.to_raw_address().as_usize() % 16 == 0 + || bt_entry_value.to_raw_address().as_usize() % 8 == 0, + "root node {:?} is not aligned to 8 or 16", + bt_entry_value + ); + + node_buffer.push(bt_entry_value); + } i += bt_entry_size; - continue; - } - let njlvals = mmtk_jl_bt_num_jlvals(bt_entry); - for j in 0..njlvals { - let bt_entry_value = mmtk_jl_bt_entry_jlvalue(bt_entry, j); - - // captures wrong root nodes before creating the work - debug_assert!( - bt_entry_value.to_raw_address().as_usize() % 16 == 0 - || bt_entry_value.to_raw_address().as_usize() % 8 == 0, - "root node {:?} is not aligned to 8 or 16", - bt_entry_value - ); - - node_buffer.push(bt_entry_value); } - i += bt_entry_size; } // We do not need gc_queue_remset from gc.c (we are not using remset in the thread) @@ -214,6 +216,12 @@ impl SweepVMSpecific { } } +impl Default for SweepVMSpecific { + fn default() -> Self { + Self::new() + } +} + impl GCWork for SweepVMSpecific { fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { // call sweep malloced arrays and sweep stack pools From 85b728f66bf8fc1b1746de54b0c41bbb659d98c4 Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Wed, 8 Jan 2025 05:36:51 +0000 Subject: [PATCH 05/12] Applying cargo fmt --- mmtk/src/julia_scanning.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mmtk/src/julia_scanning.rs b/mmtk/src/julia_scanning.rs index ff5c2aba..ca9a6def 100644 --- a/mmtk/src/julia_scanning.rs +++ b/mmtk/src/julia_scanning.rs @@ -647,7 +647,10 @@ pub unsafe fn mmtk_jl_bt_num_uintvals(bt_entry: *mut jl_bt_element_t) -> usize { (entry >> 3) & 0x7 } -pub unsafe fn mmtk_jl_bt_entry_jlvalue(bt_entry: *mut jl_bt_element_t, i: usize) -> ObjectReference { +pub unsafe fn mmtk_jl_bt_entry_jlvalue( + bt_entry: *mut jl_bt_element_t, + i: usize, +) -> ObjectReference { let entry = unsafe { (*bt_entry.add(2 + i)).__bindgen_anon_1.jlvalue }; debug_assert!(!entry.is_null()); unsafe { ObjectReference::from_raw_address_unchecked(Address::from_mut_ptr(entry)) } From 23e2f68398f219159db188b5ce62cc1baab7c0a7 Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Wed, 8 Jan 2025 10:49:05 +0000 Subject: [PATCH 06/12] Skip Allocation profiler test --- .github/scripts/ci-test-patching.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/ci-test-patching.sh b/.github/scripts/ci-test-patching.sh index 192feef1..8597684e 100755 --- a/.github/scripts/ci-test-patching.sh +++ b/.github/scripts/ci-test-patching.sh @@ -46,6 +46,7 @@ declare -a tests_to_skip=( '@test length(\[a for a in prof.allocs if a.type == MyType\]) >= 1' "$JULIA_PATH/stdlib/Profile/test/allocs.jl" '@test length(prof.allocs) >= 1' "$JULIA_PATH/stdlib/Profile/test/allocs.jl" '@test length(filter(a->a.type <: type, profile.allocs)) >= NUM_TASKS' "$JULIA_PATH/stdlib/Profile/test/allocs.jl" + '@test length(profile.allocs) >= 2\*NUM_TASKS' "$JULIA_PATH/stdlib/Profile/test/allocs.jl" # Test that expects information from heap snapshot which is currently not available in MMTk '@test contains(sshot, "redact_this")' "$JULIA_PATH/stdlib/Profile/test/runtests.jl" From fbdae4e0d7bce2ef6c9c6bef6e198d204dcb4dc0 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Tue, 14 Jan 2025 23:46:47 +0000 Subject: [PATCH 07/12] Allow setting Julia version from comments --- .github/scripts/ci-checkout.sh | 4 ++-- .github/workflows/binding-tests.yml | 14 ++++++++++---- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.github/scripts/ci-checkout.sh b/.github/scripts/ci-checkout.sh index 5b42aacb..ee4d850b 100755 --- a/.github/scripts/ci-checkout.sh +++ b/.github/scripts/ci-checkout.sh @@ -4,8 +4,8 @@ set -ex # We may later allow setting up a specific version of Julia using comments # in the PR, but for now we just use the latest master from JuliaLang -JULIA_URL=https://github.com/JuliaLang/julia.git -JULIA_VERSION=master +JULIA_URL=https://github.com/$1.git +JULIA_VERSION=$2 rm -rf $JULIA_PATH git clone $JULIA_URL $JULIA_PATH diff --git a/.github/workflows/binding-tests.yml b/.github/workflows/binding-tests.yml index 57235058..c27d1507 100644 --- a/.github/workflows/binding-tests.yml +++ b/.github/workflows/binding-tests.yml @@ -9,6 +9,12 @@ on: moving: required: true type: string + julia_repo: + required: true + type: string + julia_ref: + required: true + type: string jobs: build-debug: @@ -17,7 +23,7 @@ jobs: - uses: actions/checkout@v2 - name: Setup environments run: | - ./.github/scripts/ci-checkout.sh + ./.github/scripts/ci-checkout.sh ${{ inputs.julia_repo }} ${{ inputs.julia_ref }} ./.github/scripts/ci-setup.sh # removing these as they cause a conflict within bindgen sudo rm -rf /usr/lib/llvm-14 @@ -39,7 +45,7 @@ jobs: - uses: actions/checkout@v2 - name: Setup environments run: | - ./.github/scripts/ci-checkout.sh + ./.github/scripts/ci-checkout.sh ${{ inputs.julia_repo }} ${{ inputs.julia_ref }} ./.github/scripts/ci-setup.sh # removing these as they cause a conflict within bindgen sudo rm -rf /usr/lib/llvm-14 @@ -61,7 +67,7 @@ jobs: - uses: actions/checkout@v2 - name: Setup environments run: | - ./.github/scripts/ci-checkout.sh + ./.github/scripts/ci-checkout.sh ${{ inputs.julia_repo }} ${{ inputs.julia_ref }} ./.github/scripts/ci-setup.sh # removing these as they cause a conflict within bindgen sudo rm -rf /usr/lib/llvm-14 @@ -83,7 +89,7 @@ jobs: - uses: actions/checkout@v2 - name: Setup environments run: | - ./.github/scripts/ci-checkout.sh + ./.github/scripts/ci-checkout.sh ${{ inputs.julia_repo }} ${{ inputs.julia_ref }} ./.github/scripts/ci-setup.sh # removing these as they cause a conflict within bindgen sudo rm -rf /usr/lib/llvm-14 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79384d73..72d7a7ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,28 @@ concurrency: cancel-in-progress: true jobs: + julia-version: + runs-on: ubuntu-latest + env: + JULIA_REPO_DEFAULT: JuliaLang/julia + JULIA_REF_DEFAULT: master + outputs: + julia_repo: ${{ steps.print.outputs.julia_repo }} + julia_ref: ${{ steps.print.outputs.julia_ref }} + steps: + - name: Check Julia revisions + uses: qinsoon/comment-env-vars@1.1.0 + with: + pull_request: ${{ github.event.pull_request.number }} + token: ${{ secrets.GITHUB_TOKEN }} + default_env: 'JULIA_REPO=${{ env.JULIA_REPO_DEFAULT }},JULIA_REF=${{ env.JULIA_REF_DEFAULT }}' + - id: print + run: | + echo "julia_repo=${{ env.JULIA_REPO }}" >> $GITHUB_OUTPUT + echo "julia_ref=${{ env.JULIA_REF }}" >> $GITHUB_OUTPUT + binding-tests: + needs: julia-version strategy: fail-fast: false matrix: @@ -24,3 +45,5 @@ jobs: with: gc_plan: ${{ matrix.gc_plan }} moving: ${{ matrix.moving }} + julia_repo: ${{ needs.julia-version.outputs.julia_repo }} + julia_ref: ${{ needs.julia-version.outputs.julia_ref }} From ecc9f852b68b17796830344d39ab73e3c697ba77 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Wed, 15 Jan 2025 03:03:44 +0000 Subject: [PATCH 08/12] Put ffi check to a different job. Add another job to run with generated ffi --- .github/scripts/ci-ffi.sh | 5 ---- .github/workflows/binding-tests.yml | 40 ++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/.github/scripts/ci-ffi.sh b/.github/scripts/ci-ffi.sh index 76f2c497..8caa28dd 100755 --- a/.github/scripts/ci-ffi.sh +++ b/.github/scripts/ci-ffi.sh @@ -6,10 +6,5 @@ pushd $MMTK_JULIA_DIR make regen-bindgen-ffi -if ! git diff --exit-code $MMTK_JULIA_DIR/mmtk/src/julia_types.rs; then - echo "Rust FFI bindings in \`julia_types.rs\` are outdated. Run \`make regen-bindgen-ffi\` from the mmtk-julia directory and make sure to include the updated file in the pull request." - exit 1 -fi - popd diff --git a/.github/workflows/binding-tests.yml b/.github/workflows/binding-tests.yml index c27d1507..50e5b29c 100644 --- a/.github/workflows/binding-tests.yml +++ b/.github/workflows/binding-tests.yml @@ -26,7 +26,25 @@ jobs: ./.github/scripts/ci-checkout.sh ${{ inputs.julia_repo }} ${{ inputs.julia_ref }} ./.github/scripts/ci-setup.sh # removing these as they cause a conflict within bindgen - sudo rm -rf /usr/lib/llvm-14 + sudo rm -rf /usr/lib/llvm-14 + sudo rm -rf /usr/lib/llvm-13 + - name: Build Julia (Debug) + run: | + ./.github/scripts/ci-build.sh debug ${{ inputs.gc_plan }} ${{ inputs.moving }} + - name: Style check + run: | + ./.github/scripts/ci-style.sh + + build-debug-regen-ffi: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - name: Setup environments + run: | + ./.github/scripts/ci-checkout.sh ${{ inputs.julia_repo }} ${{ inputs.julia_ref }} + ./.github/scripts/ci-setup.sh + # removing these as they cause a conflict within bindgen + sudo rm -rf /usr/lib/llvm-14 sudo rm -rf /usr/lib/llvm-13 - name: Check FFI bindings run: | @@ -38,6 +56,26 @@ jobs: run: | ./.github/scripts/ci-style.sh + check-ffi: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - name: Setup environments + run: | + ./.github/scripts/ci-checkout.sh ${{ inputs.julia_repo }} ${{ inputs.julia_ref }} + ./.github/scripts/ci-setup.sh + # removing these as they cause a conflict within bindgen + sudo rm -rf /usr/lib/llvm-14 + sudo rm -rf /usr/lib/llvm-13 + - name: Regenerate FFI bindings + run: | + ./.github/scripts/ci-ffi.sh + - run: | + if ! git diff --exit-code $MMTK_JULIA_DIR/mmtk/src/julia_types.rs; then + echo "Rust FFI bindings in \`julia_types.rs\` are outdated. Run \`make regen-bindgen-ffi\` from the mmtk-julia directory and make sure to include the updated file in the pull request." + exit 1 + fi + build-test-other: runs-on: ubuntu-22.04 timeout-minutes: 360 From 38cf7c491e52cf7354b81fe52f2b05ecef63239b Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Wed, 15 Jan 2025 23:32:54 +0000 Subject: [PATCH 09/12] Updating julia_types.rs --- mmtk/src/julia_types.rs | 150 +++------------------------------------- 1 file changed, 10 insertions(+), 140 deletions(-) diff --git a/mmtk/src/julia_types.rs b/mmtk/src/julia_types.rs index 785d6ab6..8a89740e 100644 --- a/mmtk/src/julia_types.rs +++ b/mmtk/src/julia_types.rs @@ -190,134 +190,6 @@ const _: () = { pub type pthread_t = ::std::os::raw::c_ulong; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct fenv_t { - pub __control_word: ::std::os::raw::c_ushort, - pub __glibc_reserved1: ::std::os::raw::c_ushort, - pub __status_word: ::std::os::raw::c_ushort, - pub __glibc_reserved2: ::std::os::raw::c_ushort, - pub __tags: ::std::os::raw::c_ushort, - pub __glibc_reserved3: ::std::os::raw::c_ushort, - pub __eip: ::std::os::raw::c_uint, - pub __cs_selector: ::std::os::raw::c_ushort, - pub _bitfield_align_1: [u16; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, - pub __data_offset: ::std::os::raw::c_uint, - pub __data_selector: ::std::os::raw::c_ushort, - pub __glibc_reserved5: ::std::os::raw::c_ushort, - pub __mxcsr: ::std::os::raw::c_uint, -} -#[allow(clippy::unnecessary_operation, clippy::identity_op)] -const _: () = { - ["Size of fenv_t"][::std::mem::size_of::() - 32usize]; - ["Alignment of fenv_t"][::std::mem::align_of::() - 4usize]; - ["Offset of field: fenv_t::__control_word"] - [::std::mem::offset_of!(fenv_t, __control_word) - 0usize]; - ["Offset of field: fenv_t::__glibc_reserved1"] - [::std::mem::offset_of!(fenv_t, __glibc_reserved1) - 2usize]; - ["Offset of field: fenv_t::__status_word"] - [::std::mem::offset_of!(fenv_t, __status_word) - 4usize]; - ["Offset of field: fenv_t::__glibc_reserved2"] - [::std::mem::offset_of!(fenv_t, __glibc_reserved2) - 6usize]; - ["Offset of field: fenv_t::__tags"][::std::mem::offset_of!(fenv_t, __tags) - 8usize]; - ["Offset of field: fenv_t::__glibc_reserved3"] - [::std::mem::offset_of!(fenv_t, __glibc_reserved3) - 10usize]; - ["Offset of field: fenv_t::__eip"][::std::mem::offset_of!(fenv_t, __eip) - 12usize]; - ["Offset of field: fenv_t::__cs_selector"] - [::std::mem::offset_of!(fenv_t, __cs_selector) - 16usize]; - ["Offset of field: fenv_t::__data_offset"] - [::std::mem::offset_of!(fenv_t, __data_offset) - 20usize]; - ["Offset of field: fenv_t::__data_selector"] - [::std::mem::offset_of!(fenv_t, __data_selector) - 24usize]; - ["Offset of field: fenv_t::__glibc_reserved5"] - [::std::mem::offset_of!(fenv_t, __glibc_reserved5) - 26usize]; - ["Offset of field: fenv_t::__mxcsr"][::std::mem::offset_of!(fenv_t, __mxcsr) - 28usize]; -}; -impl fenv_t { - #[inline] - pub fn __opcode(&self) -> ::std::os::raw::c_uint { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 11u8) as u32) } - } - #[inline] - pub fn set___opcode(&mut self, val: ::std::os::raw::c_uint) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(0usize, 11u8, val as u64) - } - } - #[inline] - pub unsafe fn __opcode_raw(this: *const Self) -> ::std::os::raw::c_uint { - unsafe { - ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( - ::std::ptr::addr_of!((*this)._bitfield_1), - 0usize, - 11u8, - ) as u32) - } - } - #[inline] - pub unsafe fn set___opcode_raw(this: *mut Self, val: ::std::os::raw::c_uint) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( - ::std::ptr::addr_of_mut!((*this)._bitfield_1), - 0usize, - 11u8, - val as u64, - ) - } - } - #[inline] - pub fn __glibc_reserved4(&self) -> ::std::os::raw::c_uint { - unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 5u8) as u32) } - } - #[inline] - pub fn set___glibc_reserved4(&mut self, val: ::std::os::raw::c_uint) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(11usize, 5u8, val as u64) - } - } - #[inline] - pub unsafe fn __glibc_reserved4_raw(this: *const Self) -> ::std::os::raw::c_uint { - unsafe { - ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( - ::std::ptr::addr_of!((*this)._bitfield_1), - 11usize, - 5u8, - ) as u32) - } - } - #[inline] - pub unsafe fn set___glibc_reserved4_raw(this: *mut Self, val: ::std::os::raw::c_uint) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( - ::std::ptr::addr_of_mut!((*this)._bitfield_1), - 11usize, - 5u8, - val as u64, - ) - } - } - #[inline] - pub fn new_bitfield_1( - __opcode: ::std::os::raw::c_uint, - __glibc_reserved4: ::std::os::raw::c_uint, - ) -> __BindgenBitfieldUnit<[u8; 2usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 11u8, { - let __opcode: u32 = unsafe { ::std::mem::transmute(__opcode) }; - __opcode as u64 - }); - __bindgen_bitfield_unit.set(11usize, 5u8, { - let __glibc_reserved4: u32 = unsafe { ::std::mem::transmute(__glibc_reserved4) }; - __glibc_reserved4 as u64 - }); - __bindgen_bitfield_unit - } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct arraylist_t { pub len: usize, pub max: usize, @@ -2219,7 +2091,6 @@ pub struct _jl_task_t { pub last_started_running_at: std_atomic, pub running_time_ns: std_atomic, pub finished_at: std_atomic, - pub fenv: fenv_t, pub tid: std_atomic, pub threadpoolid: i8, pub reentrant_timing: u8, @@ -2232,7 +2103,7 @@ pub struct _jl_task_t { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of _jl_task_t"][::std::mem::size_of::<_jl_task_t>() - 256usize]; + ["Size of _jl_task_t"][::std::mem::size_of::<_jl_task_t>() - 224usize]; ["Alignment of _jl_task_t"][::std::mem::align_of::<_jl_task_t>() - 8usize]; ["Offset of field: _jl_task_t::next"][::std::mem::offset_of!(_jl_task_t, next) - 0usize]; ["Offset of field: _jl_task_t::queue"][::std::mem::offset_of!(_jl_task_t, queue) - 8usize]; @@ -2262,21 +2133,20 @@ const _: () = { [::std::mem::offset_of!(_jl_task_t, running_time_ns) - 128usize]; ["Offset of field: _jl_task_t::finished_at"] [::std::mem::offset_of!(_jl_task_t, finished_at) - 136usize]; - ["Offset of field: _jl_task_t::fenv"][::std::mem::offset_of!(_jl_task_t, fenv) - 144usize]; - ["Offset of field: _jl_task_t::tid"][::std::mem::offset_of!(_jl_task_t, tid) - 176usize]; + ["Offset of field: _jl_task_t::tid"][::std::mem::offset_of!(_jl_task_t, tid) - 144usize]; ["Offset of field: _jl_task_t::threadpoolid"] - [::std::mem::offset_of!(_jl_task_t, threadpoolid) - 178usize]; + [::std::mem::offset_of!(_jl_task_t, threadpoolid) - 146usize]; ["Offset of field: _jl_task_t::reentrant_timing"] - [::std::mem::offset_of!(_jl_task_t, reentrant_timing) - 179usize]; + [::std::mem::offset_of!(_jl_task_t, reentrant_timing) - 147usize]; ["Offset of field: _jl_task_t::gcstack"] - [::std::mem::offset_of!(_jl_task_t, gcstack) - 184usize]; + [::std::mem::offset_of!(_jl_task_t, gcstack) - 152usize]; ["Offset of field: _jl_task_t::world_age"] - [::std::mem::offset_of!(_jl_task_t, world_age) - 192usize]; - ["Offset of field: _jl_task_t::ptls"][::std::mem::offset_of!(_jl_task_t, ptls) - 200usize]; + [::std::mem::offset_of!(_jl_task_t, world_age) - 160usize]; + ["Offset of field: _jl_task_t::ptls"][::std::mem::offset_of!(_jl_task_t, ptls) - 168usize]; ["Offset of field: _jl_task_t::excstack"] - [::std::mem::offset_of!(_jl_task_t, excstack) - 208usize]; - ["Offset of field: _jl_task_t::eh"][::std::mem::offset_of!(_jl_task_t, eh) - 216usize]; - ["Offset of field: _jl_task_t::ctx"][::std::mem::offset_of!(_jl_task_t, ctx) - 224usize]; + [::std::mem::offset_of!(_jl_task_t, excstack) - 176usize]; + ["Offset of field: _jl_task_t::eh"][::std::mem::offset_of!(_jl_task_t, eh) - 184usize]; + ["Offset of field: _jl_task_t::ctx"][::std::mem::offset_of!(_jl_task_t, ctx) - 192usize]; }; pub type jl_task_t = _jl_task_t; #[repr(C)] From 8787143fe4f47fda34cfdb1ad08d63429b4f6273 Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Thu, 16 Jan 2025 00:35:17 +0000 Subject: [PATCH 10/12] Set MMTK_JULIA_DIR before run ffi check --- .github/workflows/binding-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/binding-tests.yml b/.github/workflows/binding-tests.yml index 50e5b29c..3cd1ffa5 100644 --- a/.github/workflows/binding-tests.yml +++ b/.github/workflows/binding-tests.yml @@ -71,6 +71,7 @@ jobs: run: | ./.github/scripts/ci-ffi.sh - run: | + MMTK_JULIA_DIR=$(realpath $(dirname "$0"))/../mmtk-julia/mmtk-julia if ! git diff --exit-code $MMTK_JULIA_DIR/mmtk/src/julia_types.rs; then echo "Rust FFI bindings in \`julia_types.rs\` are outdated. Run \`make regen-bindgen-ffi\` from the mmtk-julia directory and make sure to include the updated file in the pull request." exit 1 From c2b3da14742b1e95ebae89c5bceae281cc5d589e Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Thu, 16 Jan 2025 05:59:03 +0000 Subject: [PATCH 11/12] Updating version; Minor fix in julia_scanning --- mmtk/Cargo.lock | 2 +- mmtk/Cargo.toml | 2 +- mmtk/src/julia_scanning.rs | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mmtk/Cargo.lock b/mmtk/Cargo.lock index 593cdc9a..0b567d27 100644 --- a/mmtk/Cargo.lock +++ b/mmtk/Cargo.lock @@ -764,7 +764,7 @@ dependencies = [ [[package]] name = "mmtk-julia" -version = "0.30.0" +version = "0.30.3" dependencies = [ "atomic 0.4.6", "bindgen", diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index 828e63e6..918a680a 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mmtk-julia" -version = "0.30.0" +version = "0.30.3" authors = ["Eduardo Souza ", "Yi Lin "] build = "build.rs" edition = "2018" diff --git a/mmtk/src/julia_scanning.rs b/mmtk/src/julia_scanning.rs index ca9a6def..275f91e3 100644 --- a/mmtk/src/julia_scanning.rs +++ b/mmtk/src/julia_scanning.rs @@ -316,9 +316,7 @@ pub unsafe fn scan_julia_object>(obj: Address, clos let restriction = (*bpart_ptr).restriction._M_i; let offset = mmtk_decode_restriction_value(restriction); let slot = Address::from_ptr(::std::ptr::addr_of!((*bpart_ptr).restriction)); - if restriction - offset != 0 { - process_offset_slot(closure, slot, offset); - } + process_offset_slot(closure, slot, offset); } debug_assert!( (*layout).nfields > 0 && (*layout).fielddesc_type_custom() != 3, From 52a928cb3aa35fb4477bf3d612215bc1a8890e59 Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Thu, 16 Jan 2025 10:08:32 +0000 Subject: [PATCH 12/12] Fixing 0 slot --- mmtk/src/julia_scanning.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mmtk/src/julia_scanning.rs b/mmtk/src/julia_scanning.rs index 275f91e3..ca9a6def 100644 --- a/mmtk/src/julia_scanning.rs +++ b/mmtk/src/julia_scanning.rs @@ -316,7 +316,9 @@ pub unsafe fn scan_julia_object>(obj: Address, clos let restriction = (*bpart_ptr).restriction._M_i; let offset = mmtk_decode_restriction_value(restriction); let slot = Address::from_ptr(::std::ptr::addr_of!((*bpart_ptr).restriction)); - process_offset_slot(closure, slot, offset); + if restriction - offset != 0 { + process_offset_slot(closure, slot, offset); + } } debug_assert!( (*layout).nfields > 0 && (*layout).fielddesc_type_custom() != 3,