| Age | Commit message (Collapse) | Author |
|
* ZJIT: Profile opt_aref
* ZJIT: Add test for opt_aref
* ZJIT: Move test and add hash opt test
* ZJIT: Update zjit bindgen
* ZJIT: Add inspect calls to opt_aref tests
|
|
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
|
|
The Counter::name() method creates a new String on every call, each call allocates memory and copies the string. Using %'static str would reduce memory pressure. The change is safe as no breaking changes to the API
|
|
|
|
Follow-up on https://github.com/ruby/ruby/pull/14661
Unlike SendWithoutBlockDirect, `args` has every argument given to the C
call. So there's no `+ 1` for this HIR.
|
|
* ZJIT: Add HIR for CCallWithFrame
* ZJIT: Update stats to count not inlined cfunc calls
* ZJIT: Stops optimizing SendWithoutBlock when TracePoint is activated
* ZJIT: Fallback to SendWithoutBlock when CCallWithFrame has too many args
* ZJIT: Rename cfun -> cfunc
|
|
|
|
* ZJIT: Add NoSingletonClass patch point
This patch point makes sure that when the object has a singleton class,
the JIT code is invalidated. As of now, this is only needed for C call
optimization.
In YJIT, the singleton class guard only applies to Array, Hash, and String.
But in ZJIT, we may optimize C calls from gems (e.g. `sqlite3`). So the
patch point needs to be applied to a broader range of classes.
* ZJIT: Only generate NoSingletonClass guard when the type can have singleton class
* ZJIT: Update or forget NoSingletonClass patch point when needed
|
|
|
|
When we investigate guard failure issues, we sometimes need to use
profile num around 100k (e.g. `lobsters` in ruby-bench).
This change is to allow that.
|
|
|
|
This re-applies https://github.com/ruby/ruby/pull/14629 / 40bb47665d3ff57e0f2eb5a9fd9e0109617015c9 by reverting https://github.com/ruby/ruby/pull/14673 / d4393772b89dab4f33c118a284d92dc80cd63c39.
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
|
|
|
|
|
|
Add side exit tracing functionality for ZJIT
|
|
|
|
CI passed on SetIvar but broke some larger Ruby tests. Needs further investigation and testing.
* Revert "ZJIT: Fix rebase issue with tests"
This reverts commit 37248c51233d827ca56471661175c56e31c3b14f.
* Revert "ZJIT: Inline attr_accessor/attr_writer to SetIvar (#14629)"
This reverts commit 40bb47665d3ff57e0f2eb5a9fd9e0109617015c9.
|
|
|
|
|
|
|
|
* ZJIT: Add stats for cfuncs that are not optimized
* ZJIT: Add IncrCounterPtr HIR instead
From `lobsters`
```
Top-20 Unoptimized C functions (73.0% of total 15,276,688):
Kernel#is_a?: 2,052,363 (13.4%)
Class#current: 1,892,623 (12.4%)
String#to_s: 975,973 ( 6.4%)
Hash#key?: 677,623 ( 4.4%)
String#empty?: 636,468 ( 4.2%)
TrueClass#===: 457,232 ( 3.0%)
Hash#[]=: 455,908 ( 3.0%)
FalseClass#===: 448,798 ( 2.9%)
ActiveSupport::OrderedOptions#_get: 377,468 ( 2.5%)
Kernel#kind_of?: 339,551 ( 2.2%)
Kernel#dup: 329,371 ( 2.2%)
String#==: 324,286 ( 2.1%)
String#include?: 297,528 ( 1.9%)
Hash#[]: 294,561 ( 1.9%)
Array#include?: 287,145 ( 1.9%)
Kernel#block_given?: 283,633 ( 1.9%)
BasicObject#!=: 278,874 ( 1.8%)
Hash#delete: 250,951 ( 1.6%)
Set#include?: 246,447 ( 1.6%)
NilClass#===: 242,776 ( 1.6%)
```
From `liquid-render`
```
Top-20 Unoptimized C functions (99.8% of total 5,195,549):
Hash#key?: 2,459,048 (47.3%)
String#to_s: 1,119,758 (21.6%)
Set#include?: 799,469 (15.4%)
Kernel#is_a?: 214,223 ( 4.1%)
Integer#<<: 171,073 ( 3.3%)
Integer#/: 127,622 ( 2.5%)
CGI::EscapeExt#escapeHTML: 56,971 ( 1.1%)
Regexp#===: 50,008 ( 1.0%)
String#empty?: 43,990 ( 0.8%)
String#===: 36,838 ( 0.7%)
String#==: 21,309 ( 0.4%)
Time#strftime: 21,251 ( 0.4%)
String#strip: 15,271 ( 0.3%)
String#scan: 13,753 ( 0.3%)
String#+@: 12,603 ( 0.2%)
Array#include?: 8,059 ( 0.2%)
String#+: 5,295 ( 0.1%)
String#dup: 4,606 ( 0.1%)
String#-@: 3,213 ( 0.1%)
Class#generate: 3,011 ( 0.1%)
```
|
|
No point taking the panic risks with RefCell when most fields in it are
already in a Cell. Put `iseq` in a Cell and we no longer need the
wrapping. Saves memory, too.
|
|
|
|
|
|
A little follow-up on https://github.com/ruby/ruby/pull/14653
Now that we don't generate a PC-less side exit at the entry block, we
shouldn't need this guard that was added by https://github.com/ruby/ruby/pull/14643.
|
|
|
|
|
|
|
|
Without this, we crash during reference update.
|
|
The old code was doing a manual HashSet/HashMap rebuild, and there isn't
a clear performance advantage over `Iterator::map`. So let's use `map`
since it looks clearer and it's easier to see that everything was indeed
updated. This also adds assertions the old code did not have by way
of as_iseq() and as_cme().
|
|
|
|
* ZJIT: Incorporate bb0-prologue and PC check into HIR
* Fix an outdated comment
* Use shallow clone for LoadPC and EntryPoint
* Reproduce the actual HIR graph to pass validation
* Fill out param types for jit_entry_block
* Add Type::from_cptr
* Add a TODO comment about Const::CPtr printing
|
|
This:
* gets us out of the business of manually writing a bunch of `if`s
* gets us more type information
* cleans up the code
* also adds `types::Numeric`
|
|
* ZJIT: Allow testing JIT code on zjit-test
* Resurrect TestingAllocator tests
|
|
ZJIT: Add stack overflow check to gen_ccall_variadic
|
|
|
|
Add test.
|
|
|
|
* ZJIT: Add polymorphism counters
* .
* .
|
|
## Context
#14409
https://github.com/ruby/ruby/pull/14409#discussion_r2350238583
>You may have noticed that this doesn't produce a New range instruction. For that you probably need to use a local variable (makes it harder for the bytecode compiler to reason about, but the JIT sees through it). If you have time, please rewrite these tests.
https://github.com/ruby/ruby/pull/14409#discussion_r2350240389
>There's some code above to do this for you: see arguments_likely_fixnums and coerce something or other
## Changes
### Refactor tests
Modify tests force the usage of `NewRangeFixnum` instruction and make tests names more consistent.
### Refactor optimize ranges
Didn't found `arguments_likely_fixnums` to be applicable unless we enable profiling for `NewRange` and change the criteria of when the optimization fires. But there were other ways to clean up the code.
Simplify the logic and move it to `type_specialize`. Deleted the standalone `optimize_ranges` function.
|
|
The stack layout is incompatible with the way we reify the stack for
generating fallback SendWithoutBlock: the receiver is an embedded VALUE
in the bytecode, not on the stack. Since we don't expect these to be
overridden often, instead of fussing about with the stack layout, just
hope for the best and PatchPoint/SideExit.
Fix https://github.com/Shopify/ruby/issues/760
|
|
It's not just the default allocator; other allocators are also leaf.
|
|
|
|
* ZJIT: Avoid unnecessary `PopOpnds` codegen
If there's no opnds to restore, we don't need to do anything.
* ZJIT: Avoid unnecessary sub_into when there's no opnds to allocate
|
|
|
|
* ZJIT: Fix disasm tests on release build
* Rename string() to hexdump()
|
|
We can use `Vec<Opnd>` instead of `Vec<(Opnd, Opnd)>` in NewHash HIR
as it's the only usage of such type, which requires special handling.
|
|
|
|
Make sure these parameter types are counted in the fallback def_types.
|
|
ZJIT: Measure writing to locals with level > 0
|