Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust YJIT #5826

Merged
merged 3 commits into from Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -4,6 +4,7 @@

# YJIT sources and tests
yjit* @maximecb @xrxr @tenderlove
yjit/* @maximecb @xrxr @tenderlove
doc/yjit/* @maximecb @xrxr @tenderlove
bootstraptest/test_yjit* @maximecb @xrxr @tenderlove
test/ruby/test_yjit* @maximecb @xrxr @tenderlove
Expand Down
55 changes: 36 additions & 19 deletions .github/workflows/yjit-ubuntu.yml
Expand Up @@ -16,33 +16,51 @@ concurrency:
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}

jobs:
cargo:
name: Rust cargo test
# GitHub Action's image seems to already contain a Rust 1.58.0.
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
# For now we can't run cargo test --offline because it complains about the
# capstone dependency, even though the dependency is optional
#- run: cargo test --offline
- run: RUST_BACKTRACE=1 cargo test
working-directory: yjit
# Also compile and test with all features enabled
- run: RUST_BACKTRACE=1 cargo test --all-features
working-directory: yjit
# Check that we can build in release mode too
- run: cargo build --release
working-directory: yjit
make:
strategy:
fail-fast: false
matrix:
test_task: ["check"] # "test-bundler-parallel",
os:
- ubuntu-20.04
# - ubuntu-18.04
yjit_opts: [
"--yjit",
"--yjit --yjit-call-threshold=1",
]
configure: ["", "cppflags=-DRUBY_DEBUG"]
include:
- test_task: "check-yjit-bindings"
configure: "--with-gcc=clang-12 --enable-yjit=dev"

- test_task: "check"
configure: "--enable-yjit" # release build

- test_task: "check"
configure: "--enable-yjit=dev"

- test_task: "check"
configure: "--enable-yjit=dev"
yjit_opts: "--yjit-call-threshold=1"

- test_task: "test-all TESTS=--repeat-count=2"
os: ubuntu-20.04
configure: ""
yjit_enable_env: RUBY_YJIT_ENABLE
configure: "--enable-yjit=dev"

- test_task: "test-bundled-gems"
os: ubuntu-20.04
configure: "cppflags=-DRUBY_DEBUG"
yjit_enable_env: RUBY_YJIT_ENABLE
fail-fast: false
configure: "--enable-yjit=dev"
env:
GITPULLOPTIONS: --no-tags origin ${{github.ref}}
RUN_OPTS: ${{ matrix.yjit_opts }}
RUBY_DEBUG: ci
runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
if: ${{ !startsWith(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
steps:
- run: mkdir build
Expand Down Expand Up @@ -76,7 +94,7 @@ jobs:
- name: Run configure
run: ../src/configure -C --disable-install-doc ${{ matrix.configure }}
- run: make incs
- run: make
- run: make -j
- run: make leaked-globals
if: ${{ matrix.test_task == 'check' }}
- run: make prepare-gems
Expand All @@ -87,7 +105,6 @@ jobs:
if: ${{ matrix.test_task == 'check' }}
- name: Enable YJIT through ENV
run: echo "RUBY_YJIT_ENABLE=1" >> $GITHUB_ENV
if: ${{ matrix.yjit_enable_env }}
- run: make -s ${{ matrix.test_task }} RUN_OPTS="$RUN_OPTS"
timeout-minutes: 60
env:
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/yjit_asm_tests.yml

This file was deleted.

46 changes: 45 additions & 1 deletion bootstraptest/test_yjit.rb
Expand Up @@ -2057,7 +2057,6 @@ def traced_method
itself
end


tracing_ractor = Ractor.new do
# 1: start tracing
events = []
Expand Down Expand Up @@ -2806,3 +2805,48 @@ def foo
foo
foo
}

# Make sure we're correctly reading RStruct's as.ary union for embedded RStructs
assert_equal '3,12', %q{
pt_struct = Struct.new(:x, :y)
p = pt_struct.new(3, 12)
def pt_inspect(pt)
"#{pt.x},#{pt.y}"
end

# Make sure pt_inspect is JITted
10.times { pt_inspect(p) }

# Make sure it's returning '3,12' instead of e.g. '3,false'
pt_inspect(p)
}

# Regression test for deadlock between branch_stub_hit and ractor_receive_if
assert_equal '10', %q{
r = Ractor.new Ractor.current do |main|
main << 1
main << 2
main << 3
main << 4
main << 5
main << 6
main << 7
main << 8
main << 9
main << 10
end

a = []
a << Ractor.receive_if{|msg| msg == 10}
a << Ractor.receive_if{|msg| msg == 9}
a << Ractor.receive_if{|msg| msg == 8}
a << Ractor.receive_if{|msg| msg == 7}
a << Ractor.receive_if{|msg| msg == 6}
a << Ractor.receive_if{|msg| msg == 5}
a << Ractor.receive_if{|msg| msg == 4}
a << Ractor.receive_if{|msg| msg == 3}
a << Ractor.receive_if{|msg| msg == 2}
a << Ractor.receive_if{|msg| msg == 1}

a.length
}