| Age | Commit message (Collapse) | Author |
|
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
Co-authored-by: Stan Lo <stan.lo@shopify.com>
|
|
|
|
This is notably faster: no need to hash indices.
Before:
```
plum% samply record ~/.rubies/ruby-zjit/bin/ruby --zjit benchmarks/getivar.rb
ruby 3.5.0dev (2025-07-10T14:40:49Z master 51252ef8d7) +ZJIT dev +PRISM [arm64-darwin24]
itr: time
#1: 5311ms
#2: 49ms
#3: 49ms
#4: 48ms
```
After:
```
plum% samply record ~/.rubies/ruby-zjit/bin/ruby --zjit benchmarks/getivar.rb
ruby 3.5.0dev (2025-07-10T15:09:06Z mb-benchmark-compile 42ffd3c1ee) +ZJIT dev +PRISM [arm64-darwin24]
itr: time
#1: 1332ms
#2: 49ms
#3: 48ms
#4: 48ms
```
|
|
* ZJIT: Improve asm comments for side exits
* Use GuardType(Type) and GuardBitEquals(VALUE)
|
|
|
|
|
|
|
|
That's not the validator's responsibility; the caller can choose to
later.
|
|
This should be a minimal C-API needed to deal with Set objects. It
supports creating the sets, checking whether an element is the set,
adding and removing elements, iterating over the elements, clearing
a set, and returning the size of the set.
Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
|
|
Previously a missed optimization for add followed by mov. While we're
at it, have Add and Sub share the same match arm in arm64_split().
|
|
|
|
Other instructions use it as an operand and #13814 especially needs it
to have an output for validation.
|
|
|
|
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
|
|
This PR adds a validator based on dataflow analysis to ZJIT. It checks that all uses are dominated by a GEN-DEF prior.
See issue https://github.com/Shopify/ruby/issues/591
This is especially useful in validating optimizations don't zap away instructions that are actually needed, e.g. DCE.
Also included: a slight refactor of the DCE code to its own function, so I can reuse it.
Note: the algorithm uses the worklist algorithm rather than the iterative version for faster convergence.
Co-Authored-By: Max Bernstein <ruby@bernsteinbear.com>
|
|
* ZJIT: Avoid optimizing locals on eval
* Maintain the local state for eval
|
|
|
|
|
|
|
|
ZJIT already can generate guard type instructions for *Exact types.
For example:
```
def test(strings)
strings.map do |string|
string.bytesize
end
end
test(["foo", "bar"])
```
```
HIR:
fn block in test:
bb0(v0:BasicObject, v1:BasicObject):
PatchPoint MethodRedefined(String@0x1014be890, bytesize@0x19f1)
v7:StringExact = GuardType v1, StringExact
v8:Fixnum = CCall bytesize@0x16fa4cc18, v7
Return v8
```
But zjit only supported guarding fixnums so this script would panic.
This commit adds support for guarding *Exact types.
|
|
|
|
|
|
|
|
This allows ZJIT to profile `nil?` calls and create type guards for
its receiver.
- Add `zjit_profile` to `opt_nil_p` insn
- Start profiling `opt_nil_p` calls
- Use `runtime_exact_ruby_class` instead of `exact_ruby_class` to determine
the profiled receiver class
|
|
|
|
|
|
|
|
|
|
Along the same lines as the `opnd` macro we already have, but for a
`Vec<InsnId>` instead of a single `InsnId`.
This gets a few for loops and `jit.get_opnd` calls out of the `gen_`
functions.
|
|
This PR adds a simple validator for ZJIT's HIR.
See issue https://github.com/Shopify/ruby/issues/591
|
|
Prior to this commit the debug output for negative offsets would look
like:
```
Mem64[Reg(3) - -8
```
That makes it look like we're adding instead of subtracting. After this
commit we'll print:
```
Mem64[Reg(3) - 8
```
|
|
|
|
|
|
|
|
|
|
|
|
This makes it clearer what is unimplemented when looking at HIR dumps.
|
|
|
|
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
|
|
These methods return fixed `true` or `false` so we can be certain about their return types.
|
|
|
|
|
|
|
|
|
|
* ZJIT: Stop tracking EP == BP assumption on JIT entry
* Enable test_method.rb as well
|
|
|
|
|
|
No need to be so terse.
|
|
This lets us better see what is going on, for example in pattern
matching code, which has a bunch of dynamic method lookups and
`respond_to?` sends.
|
|
This removes the GetLocal of l3 from:
def test
l3 = 3
1.times do |l2|
_ = l3
1
end
end
|