Граф коммитов

754 Коммитов

Автор SHA1 Сообщение Дата
Takashi Kokubun f51b92fe23
YJIT: Add --yjit-perf (#8697)
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
2023-10-18 21:07:03 +00:00
dependabot[bot] 58ee088bb3 Bump rustix from 0.38.2 to 0.38.19 in /yjit/bindgen
Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.38.2 to 0.38.19.
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.2...v0.38.19)

---
updated-dependencies:
- dependency-name: rustix
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 12:34:10 -07:00
Alan Wu 36ee5d8ca8 YJIT: Fix clippy::redundant_locals
> note: `#[deny(clippy::redundant_locals)]` on by default

On Rust 1.73.0.
2023-10-17 18:36:23 -04:00
Alan Wu 2abd061e8b YJIT: Remove call to compile() on empty Assembler 2023-10-17 15:24:55 -04:00
Takashi Kokubun d458b4127f
YJIT: Add a few missing counters for send fallback (#8681) 2023-10-17 11:36:13 -04:00
Alan Wu 1f7234c015 YJIT: Lookup IDs on boot instead of binding to them
Previously, the version-controlled `cruby_bindings.inc.rs` file
contained the build-time artifact `id.h`, which nobu mentioned hinders
the goal of having fewer magic numbers in the repository.

Lookup the IDs YJIT needs on boot. It costs cycles, but it's fine since
YJIT only uses a handful of IDs at the moment. No perceptible
degradation to boot time found in my testing.
2023-10-17 11:30:35 -04:00
Takashi Kokubun 48c6cea330
YJIT: Count cold_iseq_entry by default (#8654) 2023-10-14 21:00:50 -07:00
Takashi Kokubun 5808999d30
YJIT: Fallback opt_getconstant_path for const_missing (#8623)
* YJIT: Fallback opt_getconstant_path for const_missing

* Fix a comment [ci skip]

* Remove a wrapper function
2023-10-13 08:52:23 -07:00
Alan Wu 0bf1749e9f
YJIT: Fix argument clobbering in some block_arg+rest_param calls (#8647)
Previously, for block argument callsites with some specific argument
count and callee local variable count combinations, YJIT ended up
writing over arguments that are supposed to be collected into a rest
parameter array unmodified.

Detect when clobbering would happen and avoid it. Also, place the block
handler after the stack overflow check, since it writes to new stack
space.

Reported-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-10-13 10:41:53 -04:00
Maxime Chevalier-Boisvert b2e1ddffa5
YJIT: port call threshold logic from Rust to C for performance (#8628)
* Port call threshold logic from Rust to C for performance

* Prefix global/field names with yjit_

* Fix linker error

* Fix preprocessor condition for rb_yjit_threshold_hit

* Fix third linker issue

* Exclude yjit_calls_at_interv from RJIT bindgen

---------

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-10-12 10:05:34 -04:00
Jean Boussier e3afc212ec shape.h: Make attr_index_t uint8_t
Given `SHAPE_MAX_NUM_IVS 80`, we transition to TOO_COMPLEX
way before we could overflow a 8bit counter.

This reduce the size of `rb_shape_t` from 32B to 24B.

If we decide to raise `SHAPE_MAX_NUM_IVS` we can always increase
that type again.
2023-10-11 08:33:09 +02:00
Takashi Kokubun 4d0a619f71
YJIT: Allow --yjit-trace-exits on release builds (#8619) 2023-10-10 14:54:19 -07:00
Jean Boussier 5cc44f48c5 Refactor rb_shape_transition_shape_capa to not accept capacity
This way the groth factor is encapsulated, which allows
rb_shape_transition_shape_capa to be smarter about ideal sizes.
2023-10-10 14:47:54 +02:00
Alan Wu 8cb906d706 YJIT: Simplify linker flavor check
By not allowlisting every OS that could have a GNU flavor linker,
it's also a bigger tent
2023-10-05 17:31:54 -04:00
Maxime Chevalier-Boisvert 13bde94a9f
YJIT: shink local types from 8 to 4 bytes (#8597)
* Shink local types from 8 to 4 bytes, context from 21 to 17 bytes

Use repr(packed)

* Add comment about Type being limited to 4 bits
2023-10-05 17:17:33 -04:00
Alan Wu 7d1abd5d31 YJIT: Run bindgen 2023-10-05 17:09:18 -04:00
Alan Wu 07a7c4bdaf YJIT: Remove duplicate cfp->iseq accessor 2023-10-05 16:40:27 -04:00
Alan Wu 41a6e4bdf9 YJIT: Avoid writing return value to memory in `leave`
Previously, at the end of `leave` we did
`*caller_cfp->sp = return_value`, like the interpreter.
With future changes that leaves the SP field uninitialized for C frames,
this will become problematic. For cases like returning from
`rb_funcall()`, the return value was written above the stack and
never read anyway (callers use the copy in the return register).

Leave the return value in a register at the end of `leave` and have the
code at `cfp->jit_return` decide what to do with it. This avoids the
unnecessary memory write mentioned above. For JIT-to-JIT returns, it goes
through `asm.stack_push()` and benefits from register allocation for
stack temporaries.

Mostly flat on benchmarks, with maybe some marginal speed improvements.

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-10-05 15:53:05 -04:00
Nobuyoshi Nakada cf1223348a
Remove unmatch parenthesis
```
yjit/yjit.mk:48: Extraneous text after `ifneq' directive
```
2023-10-06 03:39:33 +09:00
Thomas Hurst fd22d5debb
YJIT: Build on BSD platforms with GNU make (#8591) 2023-10-05 13:23:51 -04:00
Takashi Kokubun f834b1a40d YJIT: Add a comment for YJIT_OPTIONS [ci skip] 2023-10-04 10:28:32 -07:00
Takashi Kokubun 7db6f448ed Use a better variable name for w 2023-10-04 10:25:46 -07:00
Takashi Kokubun 577ff858bc Make the function names consistent 2023-10-04 10:25:46 -07:00
Takashi Kokubun 01c462ce6a YJIT: Move help descriptions to options.rs 2023-10-04 10:25:46 -07:00
Takashi Kokubun 465bc682a2
YJIT: Call mprotect after entry stub failure (#8582)
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2023-10-03 22:39:45 -07:00
Maxime Chevalier-Boisvert ea491802fa
YJIT: add heuristic to avoid compiling cold ISEQs (#8522)
* YJIT: Add counter to measure how often we compile "cold" ISEQs (#535)

Fix counter name in DEFAULT_COUNTERS

YJIT: add --yjit-cold-threshold, don't compile cold ISEQs

YJIT: increase default cold threshold to 200_000

Remove rb_yjit_call_threshold()

Remove conflict markers

Fix compilation errors

Threshold 1 should compile immediately

Debug deadlock issue with test_ractor

Fix call threshold issue with tests

* Revert exception threshold logic. Document option in yjid.md

* (void) for 0 parameter functions in C99

* Rename iseq_entry_cold => cold_iseq_entry

* Document --yjit-cold-threshold in ruby.c

* Update doc/yjit/yjit.md

Co-authored-by: Jean byroot Boussier <jean.boussier+github@shopify.com>

* Shorten help string to appease test

* Address bug found by Kokubun. Reorder logic.

---------

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Co-authored-by: Jean byroot Boussier <jean.boussier+github@shopify.com>
2023-10-03 17:45:46 -04:00
Takashi Kokubun 1992aef722
YJIT: Stop spilling temps on jit_prepare_routine_call (#8581)
YJIT: Remove spill_temps from jit_prepare_routine_call
2023-10-03 12:54:24 -04:00
Takashi Kokubun 0b67e3fd3e
YJIT: Chain-guard opt_mult overflow (#8554)
* YJIT: Chain-guard opt_mult overflow

* YJIT: Support regenerating Jo after Mul
2023-09-29 21:55:48 -04:00
Takashi Kokubun 0d4c4b6573
YJIT: Use registers for passing C method arguments (#8538) 2023-09-29 10:08:15 -04:00
Takashi Kokubun a8578fff98
YJIT: Remove obsoleted jit_rb_int_mul (#8539) 2023-09-29 10:01:50 -04:00
Takashi Kokubun 9aeb6e72db
YJIT: Avoid creating a vector in get_temp_regs() (#8446)
* YJIT: Avoid creating a vector in get_temp_regs()

Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>

* Remove unused import

---------

Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2023-09-15 21:41:00 -04:00
Alan Wu 7cec7d14c3
YJIT: Fix object movement bug in iseq guard for invokeblock
Since the compile-time iseq used in the guard was not marked and updated
during compaction, a runtime value reusing the address could falsely pass
the guard.

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-09-15 19:03:48 -04:00
Alan Wu 0996cf5593 YJIT: Fix and enable the unused_imports warning 2023-09-15 16:15:15 -04:00
Takashi Kokubun 982d6503b9
YJIT: Skip Insn::Comment and format! if disasm is disabled (#8441)
* YJIT: Skip Insn::Comment and format!

if disasm is disabled

Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>

* YJIT: Get rid of asm.comment

---------

Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
2023-09-14 15:49:40 -07:00
Alan Wu 0ba6c603bc YJIT: Remove UTF-8 BOM [ci skip]
/yjit/src/backend/x86_64/mod.rs Is also UTF-8 and it doesn't have the
marker. The standard recommends against it, so remove it.
2023-09-14 18:40:45 -04:00
Alan Wu 1961c5bb76
YJIT: Plug native stack overflow
Previously, TestStack#test_machine_stack_size failed pretty consistently
on ARM64 macOS, with Rust code and part of the interpreter used for
per-instruction fallback (rb_vm_invokeblock() and friends) touching the
stack guard page and crashing with SEGV. I've also seen the same test
fail on x64 Linux, though with a different symptom.
2023-09-14 17:18:45 -04:00
Takashi Kokubun fcc1699162
YJIT: Initialize Vec with capacity for iterators (#8439) 2023-09-14 10:55:00 -07:00
Takashi Kokubun cdc69da9e5
YJIT: Initialize Assembler vectors with capacity (#8437) 2023-09-14 10:10:31 -04:00
Takashi Kokubun b49be2a70f
YJIT: Skip adding past_page_bytes for past pages (#8433)
YJIT: Skip adding past_pages_bytes for past pages
2023-09-13 16:44:23 -04:00
Takashi Kokubun ff329ce428
YJIT: Make yjit_alloc_size available by default (#8426) 2023-09-13 10:48:14 -04:00
Takashi Kokubun 721d21d301
YJIT: Make compile_time_ns a default counter (#8425) 2023-09-13 10:45:40 -04:00
Takashi Kokubun 0ae7f2d1ac
YJIT: Add compilation time counter (#8417)
* YJIT: Add compilation time counter

* YJIT: Use Instant instead
2023-09-12 13:52:40 -04:00
Alan Wu 39ee3e22bd Make Kernel#lambda raise when given non-literal block
Previously, Kernel#lambda returned a non-lambda proc when given a
non-literal block and issued a warning under the `:deprecated` category.
With this change, Kernel#lambda will always return a lambda proc, if it
returns without raising.

Due to interactions with block passing optimizations, we previously had
two separate code paths for detecting whether Kernel#lambda got a
literal block. This change allows us to remove one path, the hack done
with rb_control_frame_t::block_code introduced in 85a337f for supporting
situations where Kernel#lambda returned a non-lambda proc.

[Feature #19777]

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-09-12 11:25:07 -04:00
Ian Candy 78233e8352
Add `String#getbyte` YJIT implementation (#8397)
* Add getbyte JIT implementation

Adds an implementation for String#getbyte for YJIT, along with a
bootstrap test. This should be helpful for pure Ruby implementations
and to avoid unneeded allocations.

Co-authored-by: John Hawthorn <jhawthorn@github.com>

* Skip the getbyte test for RJIT for now

---------

Co-authored-by: John Hawthorn <jhawthorn@github.com>
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-09-07 23:15:24 -04:00
Takashi Kokubun 89edce4321
YJIT: Decrease IVAR_MAX_DEPTH to 8 (#8398) 2023-09-07 23:15:08 -04:00
Takashi Kokubun fcdedf7f47
YJIT: Decrease SEND_MAX_DEPTH to 5 (#8390) 2023-09-07 14:22:34 -04:00
Aaron Patterson 0adca625ee
Remove function call for String#bytesize (#8389)
* Remove function call for String#bytesize

String size is stored in a consistent location, so we can eliminate the
function call.

* Update yjit/src/codegen.rs

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>

---------

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-09-07 09:54:05 -04:00
Alan Wu f1422e4cec YJIT: Different comment when only setting ec->cfp [ci skip] 2023-09-06 15:32:36 -04:00
Takashi Kokubun a334077b7b
YJIT: Make compiled_* stats available by default (#8379)
* YJIT: Make compiled_* stats available by default

* Update comment about default counters [ci skip]

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>

---------

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2023-09-06 09:29:33 -07:00
Alan Wu 6c4df555fd YJIT: Silence Clippy for bindgen generated code
New Clippy lint in 1.72.0 is breaking our build as GitHub has updated
their image. No point hearing about lints from generated code we don't
manually write.
2023-09-05 14:46:44 -04:00