| Age | Commit message (Collapse) | Author |
|
jump, branchif, etc don't invalidate locals in the JIT; they might in the interpreter because they can execute arbitrary code, but the JIT side exits before that happens.
|
|
Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
|
|
rb_gc_writebarrier() in gen_write_barrier()
* To avoid calling rb_gc_writebarrier() with an immediate value in gen_write_barrier(),
and avoid the LIR jump issue.
|
|
gen_write_barrier()"
* This reverts commit 623559faa3dd0927b4034a752226a30ae8821604.
* There is an issue with the jump in LIR, see https://github.com/ruby/ruby/pull/15542.
|
|
|
|
|
|
gen_write_barrier()
|
|
This reverts commit 2f151e76b5dc578026706b31f054d5caf5374b05.
The SP decrement (push) before the call do not match up with
the pops after the call, so registers were restored incorrectly.
Code from:
./miniruby --zjit-call-threshold=1 --zjit-dump-disasm -e 'p Time.new(1992, 9, 23, 23, 0, 0, :std)'
str x11, [sp, #-0x10]!
str x12, [sp, #-0x10]!
stur x7, [sp] # last argument
mov x0, x20
mov x7, x6
mov x6, x5
mov x5, x4
mov x4, x3
mov x3, x2
mov x2, x1
ldur x1, [x29, #-0x20]
mov x16, #0xccfc
movk x16, #0x2e7, lsl #16
movk x16, #1, lsl #32
blr x16
ldr x12, [sp], #0x10 # supposed to match str x12, [sp, #-0x10]!, but got last argument
ldr x11, [sp], #0x10
|
|
Before this change, GC'ing any Ractor object caused you to lose all
enabled tracepoints across all ractors (even main). Now tracepoints are
ractor-local and this doesn't happen. Internal events are still global.
Fixes [Bug #19112]
|
|
This can happen with documentation updates and we don't want
those to trip on ZJIT tests.
Redact the whole name since names like "_bi342" aren't that helpful
anyways.
|
|
Avoid garbage reads from locals in eval.
Before the fix the test fails with
<"[\"x\", \"x\", \"x\", \"x\"]"> expected but was
<"[\"x\", \"x\", \"x\", \"x286326928\"]">.
|
|
|
|
ZJIT: Add stack support for CCalls
|
|
|
|
|
|
It's just a nicety (they fit fine as CUInt32) but this makes printing
look nicer in real execution and also in tests (helps with #15489).
Co-authored-by: Randy Stauner <randy@r4s6.net>
|
|
|
|
Fix https://github.com/Shopify/ruby/issues/874
|
|
|
|
No point doing the manual size unit conversion for add. Sorry, no new
tests since there is no way to generate a LoadField with a negative
offset from ruby code AFAICT. Careful with the `as` casts.
|
|
* ZJIT: Fold LoadField on frozen objects to constants
When accessing instance variables from frozen objects via attr_reader/
attr_accessor, fold the LoadField instruction to a constant at compile
time. This enables further optimizations like constant propagation.
- Add fold_getinstancevariable_frozen optimization in Function::optimize
- Check if receiver type has a known ruby_object() that is frozen
- Read the field value at compile time and replace with Const instruction
- Add 10 unit tests covering various value types (fixnum, string, symbol,
nil, true/false) and negative cases (unfrozen, dynamic receiver)
* Run zjit-test-update
* Add a test that we don't fold non-BasicObject
* Small cleanups
---------
Co-authored-by: Max Bernstein <ruby@bernsteinbear.com>
Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
|
|
|
|
This fixes a crash when the new shape after a transition is too complex;
we need to check that it's not complex before trying to read by index.
|
|
* ZJIT: Add dump to file for --zjit-stats
* ZJIT: Rename --zjit-stats=quiet to --zjit-stats-quiet
|
|
This adds comments to the hir dump output like this:
v13:BasicObject = SendWithoutBlock v6, :test, v11 # SendFallbackReason: Complex argument passing
|
|
|
|
|
|
|
|
|
|
|
|
Fixes https://github.com/Shopify/ruby/issues/902
This pull request adds code generation for dividing fixnums.
Testing confirms the normal case, flooring, and side-exiting on division by zero.
|
|
|
|
ZJIT: Print local variable names GetLocal and SetLocal instructions
|
|
Its definition changes depending on e.g. whether there is YJIT in the
build.
|
|
Since we do a decent job of pre-sizing objects, don't handle the case where we would need to re-size an object. Also don't handle too-complex shapes.
lobsters stats before:
```
Top-20 calls to C functions from JIT code (79.4% of total 90,051,140):
rb_vm_opt_send_without_block: 19,762,433 (21.9%)
rb_vm_setinstancevariable: 7,698,314 ( 8.5%)
rb_hash_aref: 6,767,461 ( 7.5%)
rb_vm_env_write: 5,373,080 ( 6.0%)
rb_vm_send: 5,049,229 ( 5.6%)
rb_vm_getinstancevariable: 4,535,259 ( 5.0%)
rb_obj_is_kind_of: 3,746,306 ( 4.2%)
rb_ivar_get_at_no_ractor_check: 3,745,237 ( 4.2%)
rb_vm_invokesuper: 3,037,467 ( 3.4%)
rb_ary_entry: 2,351,983 ( 2.6%)
rb_vm_opt_getconstant_path: 1,344,740 ( 1.5%)
rb_vm_invokeblock: 1,184,474 ( 1.3%)
Hash#[]=: 1,064,288 ( 1.2%)
rb_gc_writebarrier: 1,006,972 ( 1.1%)
rb_ec_ary_new_from_values: 902,687 ( 1.0%)
fetch: 898,667 ( 1.0%)
rb_str_buf_append: 833,787 ( 0.9%)
rb_class_allocate_instance: 822,024 ( 0.9%)
Hash#fetch: 699,580 ( 0.8%)
_bi20: 682,068 ( 0.8%)
Top-4 setivar fallback reasons (100.0% of total 7,732,326):
shape_transition: 6,032,109 (78.0%)
not_monomorphic: 1,469,300 (19.0%)
not_t_object: 172,636 ( 2.2%)
too_complex: 58,281 ( 0.8%)
```
lobsters stats after:
```
Top-20 calls to C functions from JIT code (79.0% of total 88,322,656):
rb_vm_opt_send_without_block: 19,777,880 (22.4%)
rb_hash_aref: 6,771,589 ( 7.7%)
rb_vm_env_write: 5,372,789 ( 6.1%)
rb_gc_writebarrier: 5,195,527 ( 5.9%)
rb_vm_send: 5,049,145 ( 5.7%)
rb_vm_getinstancevariable: 4,538,485 ( 5.1%)
rb_obj_is_kind_of: 3,746,241 ( 4.2%)
rb_ivar_get_at_no_ractor_check: 3,745,172 ( 4.2%)
rb_vm_invokesuper: 3,037,157 ( 3.4%)
rb_ary_entry: 2,351,968 ( 2.7%)
rb_vm_setinstancevariable: 1,703,337 ( 1.9%)
rb_vm_opt_getconstant_path: 1,344,730 ( 1.5%)
rb_vm_invokeblock: 1,184,290 ( 1.3%)
Hash#[]=: 1,061,868 ( 1.2%)
rb_ec_ary_new_from_values: 902,666 ( 1.0%)
fetch: 898,666 ( 1.0%)
rb_str_buf_append: 833,784 ( 0.9%)
rb_class_allocate_instance: 821,778 ( 0.9%)
Hash#fetch: 755,913 ( 0.9%)
Top-4 setivar fallback reasons (100.0% of total 1,703,337):
not_monomorphic: 1,472,405 (86.4%)
not_t_object: 172,629 (10.1%)
too_complex: 58,281 ( 3.4%)
new_shape_needs_extension: 22 ( 0.0%)
```
I also noticed that primitive printing in HIR was broken so I fixed that.
Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
|
|
We generally know the receiver's class from profile info. I see 600k of these when running lobsters.
|
|
|
|
It's used as an alternative to find-and-replace, so we should have
nothing to replace.
|
|
|
|
This commit uses the custom instruction iterator in arm64 / x86_64
instruction splitting. Once we introduce basic blocks to LIR, the
custom iterator will ensure that instructions are added to the correct
place.
|
|
This commit adds a specialized instruction iterator to the assembler
with a custom "peek" method. The reason is that we want to add basic
blocks to LIR. When we split instructions, we need to add any new
instructions to the correct basic block. The custom iterator will
maintain the correct basic block inside the assembler, that way when we
push any new instructions they will be appended to the correct place.
|
|
|
|
|
|
* All Invariant::SingleRactorMode PatchPoint are replaced by
assume_single_ractor_mode() to fix https://github.com/Shopify/ruby/issues/875
for SingleRactorMode patchpoints.
|
|
|
|
|
|
Don't call a C function.
|
|
|
|
Same as Integer#>>. Also add more strict type checks for both Integer#>>
and Integer#<<.
|
|
This will help JITs (and maybe later the interpreter) optimize
Integer#>>.
|