-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Rewrite Array#each in Ruby using Primitive #9533
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 8000 terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dca75f2
to
35f3b4e
Compare
Nice. Happy to see this working. Surprised it's so far in YJIT as well! Ideally, for YJIT, we'd like to be able to avoid doing a function call at all, so we can generate tight inlined code though, so we might need a specialized instruction instead of a cexpr? What do you think? |
I think it's possible without a new instruction. |
3c97813
to
bede16a
Compare
bede16a
to
3aaa6de
Compare
0d58851
to
4f30c21
Compare
4f30c21
to
6b5e44b
Compare
2e2cd3f
to
d98ac2c
Compare
In order to provide compatibility with TruffleRuby that implements a lot of its core library methods in Ruby, and for future versions of CRuby that is increasingly doing the same, we need to be able to filter all backtrace locations where the `path` starts with `<internal:`. [This gist](https://gist.github.com/eregon/912e6359e83781c5fa1c638d3768c526) shows the current state of the methods implemented in Ruby in CRuby, JRuby and TruffleRuby. Most recently [CRuby started implementing `Array#each` in Ruby](ruby/ruby#9533), making it usages of `each` visible in backtraces with an `<internal:array>` path. This means that in order to be compatible with CRuby 3.4, Sorbet runtime needs to start filtering out backtrace locations that start with `<internal:`. By encapsulating the caller location search logic into a singleton method, we can apply that filtering in a single location and avoid having to repeat it in multiple places.
In order to provide compatibility with TruffleRuby that implements a lot of its core library methods in Ruby, and for future versions of CRuby that is increasingly doing the same, we need to be able to filter all backtrace locations where the `path` starts with `<internal:`. [This gist](https://gist.github.com/eregon/912e6359e83781c5fa1c638d3768c526) shows the current state of the methods implemented in Ruby in CRuby, JRuby and TruffleRuby. Most recently [CRuby started implementing `Array#each` in Ruby](ruby/ruby#9533), making it usages of `each` visible in backtraces with an `<internal:array>` path. This means that in order to be compatible with CRuby 3.4, Sorbet runtime needs to start filtering out backtrace locations that start with `<internal:`. By encapsulating the caller location search logic into a singleton method, we can apply that filtering in a single location and avoid having to repeat it in multiple places.
In order to provide compatibility with TruffleRuby that implements a lot of its core library methods in Ruby, and for future versions of CRuby that is increasingly doing the same, we need to be able to filter all backtrace locations where the `path` starts with `<internal:`. [This gist](https://gist.github.com/eregon/912e6359e83781c5fa1c638d3768c526) shows the current state of the methods implemented in Ruby in CRuby, JRuby and TruffleRuby. Most recently [CRuby started implementing `Array#each` in Ruby](ruby/ruby#9533), making it usages of `each` visible in backtraces with an `<internal:array>` path. This means that in order to be compatible with CRuby 3.4, Sorbet runtime needs to start filtering out backtrace locations that start with `<internal:`. By encapsulating the caller location search logic into a singleton method, we can apply that filtering in a single location and avoid having to repeat it in multiple places.
In order to provide compatibility with TruffleRuby that implements a lot of its core library methods in Ruby, and for future versions of CRuby that is increasingly doing the same, we need to be able to filter all backtrace locations where the `path` starts with `<internal:`. [This gist](https://gist.github.com/eregon/912e6359e83781c5fa1c638d3768c526) shows the current state of the methods implemented in Ruby in CRuby, JRuby and TruffleRuby. Most recently [CRuby started implementing `Array#each` in Ruby](ruby/ruby#9533), making it usages of `each` visible in backtraces with an `<internal:array>` path. This means that in order to be compatible with CRuby 3.4, Sorbet runtime needs to start filtering out backtrace locations that start with `<internal:`. By encapsulating the caller location search logic into a singleton method, we can apply that filtering in a single location and avoid having to repeat it in multiple places.
In order to provide compatibility with TruffleRuby that implements a lot of its core library methods in Ruby, and for future versions of CRuby that is increasingly doing the same, we need to be able to filter all backtrace locations where the `path` starts with `<internal:`. [This gist](https://gist.github.com/eregon/912e6359e83781c5fa1c638d3768c526) shows the current state of the methods implemented in Ruby in CRuby, JRuby and TruffleRuby. Most recently [CRuby started implementing `Array#each` in Ruby](ruby/ruby#9533), making it usages of `each` visible in backtraces with an `<internal:array>` path. This means that in order to be compatible with CRuby 3.4, Sorbet runtime needs to start filtering out backtrace locations that start with `<internal:`. By encapsulating the caller location search logic into a singleton method, we can apply that filtering in a single location and avoid having to repeat it in multiple places.
In order to provide compatibility with TruffleRuby that implements a lot of its core library methods in Ruby, and for future versions of CRuby that is increasingly doing the same, we need to be able to filter all backtrace locations where the `path` starts with `<internal:`. [This gist](https://gist.github.com/eregon/912e6359e83781c5fa1c638d3768c526) shows the current state of the methods implemented in Ruby in CRuby, JRuby and TruffleRuby. Most recently [CRuby started implementing `Array#each` in Ruby](ruby/ruby#9533), making it usages of `each` 8000 visible in backtraces with an `<internal:array>` path. This means that in order to be compatible with CRuby 3.4, Sorbet runtime needs to start filtering out backtrace locations that start with `<internal:`. By encapsulating the caller location search logic into a singleton method, we can apply that filtering in a single location and avoid having to repeat it in multiple places.
In order to provide compatibility with TruffleRuby that implements a lot of its core library methods in Ruby, and for future versions of CRuby that is increasingly doing the same, we need to be able to filter all backtrace locations where the `path` starts with `<internal:`. [This gist](https://gist.github.com/eregon/912e6359e83781c5fa1c638d3768c526) shows the current state of the methods implemented in Ruby in CRuby, JRuby and TruffleRuby. Most recently [CRuby started implementing `Array#each` in Ruby](ruby/ruby#9533), making it usages of `each` visible in backtraces with an `<internal:array>` path. This means that in order to be compatible with CRuby 3.4, Sorbet runtime needs to start filtering out backtrace locations that start with `<internal:`. By encapsulating the caller location search logic into a singleton method, we can apply that filtering in a single location and avoid having to repeat it in multiple places.
In order to provide compatibility with TruffleRuby that implements a lot of its core library methods in Ruby, and for future versions of CRuby that is increasingly doing the same, we need to be able to filter all backtrace locations where the `path` starts with `<internal:`. [This gist](https://gist.github.com/eregon/912e6359e83781c5fa1c638d3768c526) shows the current state of the methods implemented in Ruby in CRuby, JRuby and TruffleRuby. Most recently [CRuby started implementing `Array#each` in Ruby](ruby/ruby#9533), making it usages of `each` visible in backtraces with an `<internal:array>` path. This means that in order to be compatible with CRuby 3.4, Sorbet runtime needs to start filtering out backtrace locations that start with `<internal:`. By encapsulating the caller location search logic into a singleton method, we can apply that filtering in a single location and avoid having to repeat it in multiple places.
) In order to provide compatibility with TruffleRuby that implements a lot of its core library methods in Ruby, and for future versions of CRuby that is increasingly doing the same, we need to be able to filter all backtrace locations where the `path` starts with `<internal:`. [This gist](https://gist.github.com/eregon/912e6359e83781c5fa1c638d3768c526) shows the current state of the methods implemented in Ruby in CRuby, JRuby and TruffleRuby. Most recently [CRuby started implementing `Array#each` in Ruby](ruby/ruby#9533), making it usages of `each` visible in backtraces with an `<internal:array>` path. This means that in order to be compatible with CRuby 3.4, Sorbet runtime needs to start filtering out backtrace locations that start with `<internal:`. By encapsulating the caller location search logic into a singleton method, we can apply that filtering in a single location and avoid having to repeat it in multiple places.
Same as #6687, but race condition-free.
microbenchmark
Interpreter
Thanks to
Primitive
, the interpreter doesn't slow down.YJIT
Even faster than #6687.
yjit-bench
See #9622.