69650 Commits

Author SHA1 Message Date
John Hawthorn
3a3f706698 Additional invokesuper tests 2021-10-20 18:19:39 -04:00
John Hawthorn
3ecc6befcd Implement invokesuper using cfp->ep[ME] check
This fixes and re-enables invokesuper, replacing the existing guards
with a guard on the method entry for the EP.
2021-10-20 18:19:39 -04:00
John Hawthorn
fbde1d9bee Store block callee_cme in darray
This allows a block version to have dependencies on multiple CMEs.
2021-10-20 18:19:39 -04:00
Maxime Chevalier-Boisvert
9d5b3e1d0f Add a small test for the code GC 2021-10-20 18:19:39 -04:00
John Hawthorn
e527912fe0 Use jit_prepare_routine_call 2021-10-20 18:19:39 -04:00
John Hawthorn
69a2531249 Implement gen_putstring 2021-10-20 18:19:39 -04:00
Ufuk Kayserilioglu
2c93ef7ab3 Add YJIT logo
Adding YJIT logo with a link to https://yjit.org
2021-10-20 18:19:39 -04:00
Alan Wu
2bd99d7d7a typo, rename, comment 2021-10-20 18:19:39 -04:00
John Hawthorn
812597676b Avoid immediate side exits in checktype
Previously checktype only supported heap objects, however it's not
uncommon to receive an immediate, for example when string interpolating
a Symbol or Integer.
2021-10-20 18:19:39 -04:00
Alan Wu
54db64f7a5 filter out internal events. add comments. reorder 2021-10-20 18:19:39 -04:00
Alan Wu
4b815abb37 Lock, don't loock. 2021-10-20 18:19:39 -04:00
Aaron Patterson
0ca04e2dd4 Only clear the JIT function when we invalidate the entry block
We should only clear the JIT function when the entry point is
invalidated.  Right now we only support compiling functions with a PC
offset of zero (functions that take optional parameters can start at
non-zero PC), so this patch just checks that the index is 0 before
clearing the jit function
2021-10-20 18:19:39 -04:00
Jean Boussier
b5a0baf1c0 Allow to toggle YJIT stats collection from runtime
For use cases where you want to collect the metrics
for a specific piece of code (typically a web request)
you can have the stats turned off by default and then
turn them on at runtime before executing the code you care
about.
2021-10-20 18:19:39 -04:00
Alan Wu
924e3ca84f fix typo 2021-10-20 18:19:39 -04:00
Alan Wu
bd876c243a TracePoint support
This change fixes some cases where YJIT fails to fire tracing events.
Most of the situations YJIT did not handle correctly involves enabling
tracing while running inside generated code.

A new operation to invalidate all generated code is added, which uses
patching to make generated code exit at the next VM instruction
boundary. A new routine called `jit_prepare_routine_call()` is
introduced to facilitate this and should be used when generating code
that could allocate, or could otherwise use `RB_VM_LOCK_ENTER()`.

The `c_return` event is fired in the middle of an instruction as opposed
to at an instruction boundary, so it requires special handling. C method
call return points are patched to go to a fucntion which does everything
the interpreter does, including firing the `c_return` event. The
generated code for C method calls normally does not fire the event.

Invalided code should not change after patching so the exits are not
clobbered. A new variable is introduced to track the region of code that
should not change.
2021-10-20 18:19:39 -04:00
Maxime Chevalier-Boisvert
0562459473 Redo the ivtable lookp once the ivar is set 2021-10-20 18:19:39 -04:00
Maxime Chevalier-Boisvert
b3e993a64b Make sure that there is always an index table entry for getivars 2021-10-20 18:19:39 -04:00
Maxime Chevalier-Boisvert
7f2828d1c8 Update README 2021-10-20 18:19:39 -04:00
Jean Boussier
0dc3bba6f2 Allow to compile with --yjit-stats support but not the full RUBY_DEBUG
RUBY_DEBUG have a very significant performance overhead. Enough that
YJIT with RUBY_DEBUG is noticeably slower than the interpreter without
RUBY_DEBUG.

This makes it hard to collect yjit-stats in production environments.

By allowing to collect JIT statistics without the RUBy_DEBUG overhead,
I hope to make such use cases smoother.
2021-10-20 18:19:39 -04:00
eileencodes
2ba090a1f9 Add toregexp to yjit
The FIXME is there so we remember to investigate why insns clears the
temporary array. Is this necessary? If it's not we can remove it from
both.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-10-20 18:19:39 -04:00
Maxime Chevalier-Boisvert
dd5082d7ca Use cmov to handle Qundef case in getivar instead of side-exit 2021-10-20 18:19:39 -04:00
Maxime Chevalier-Boisvert
c4b99d6a42 Add ASM comment 2021-10-20 18:19:39 -04:00
Mike Dalessio
918668b4a9 update README with correct repository URL 2021-10-20 18:19:39 -04:00
John Hawthorn
e18b0b6eba Implement putspecialobject 2021-10-20 18:19:39 -04:00
John Hawthorn
3edf29668e Add opt_regexpmatch2 2021-10-20 18:19:39 -04:00
John Hawthorn
595fdf8d66 Assign directly to C_ARG_REGS now when possible 2021-10-20 18:19:39 -04:00
John Hawthorn
8fa0ee4d40 Use callee-saved regs for REG_SP, REG_EP, REG_CFP 2021-10-20 18:19:39 -04:00
John Hawthorn
ed8aa3409a Detach mapping to local in ctx_set_local_type
Similar to the previous fix to ctx_clear_local_types, we must detach
mappings to a local if we are changing its value.
2021-10-20 18:19:38 -04:00
John Hawthorn
6d852e847e Fix stack size check for ctx_get_opnd_type
Previously all stack operands would become unknown once the stack grew
beyond a certain size. This worked, but unnecessarily hid available
information.
2021-10-20 18:19:38 -04:00
John Hawthorn
48dca3348a Move yjit_type_of_value into yjit_core.c 2021-10-20 18:19:38 -04:00
John Hawthorn
d78ea4abec Implement verify_ctx for debugging 2021-10-20 18:19:38 -04:00
John Hawthorn
a02002dc4f More detection of immediate constants 2021-10-20 18:19:38 -04:00
John Hawthorn
2e707ee66f Don't generate entry point when PC != 0
If we hit this at PC > 0 (ie. with an optional argument) the provided
types and context are likely incorrect and it is likely this block can't
be used.
2021-10-20 18:19:38 -04:00
eileencodes
d2e8b99b5b Implement tostring instruction for yjit
Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-10-20 18:19:38 -04:00
Alan Wu
5b4305f71c Simpler fix for -DUSE_EMBED_CI=0
Nobu pointed out that saving the old ci to a local is enough to keep it
reachable.
2021-10-20 18:19:38 -04:00
Alan Wu
8cf01dd25c Revert "Fix use-after-free on USE_EMBED_CI=0"
This reverts commit 1e0f2e4b09ca9443524acf4b50ffd50a80f330f3.
2021-10-20 18:19:38 -04:00
John Hawthorn
641ef34dde Allow upgrading first N types when stack is large 2021-10-20 18:19:38 -04:00
John Hawthorn
5d155fc8a1 Improve comments for mapping functions 2021-10-20 18:19:38 -04:00
John Hawthorn
786e512178 Add regression test of invalid mapping merge
This should have referenced MAX_TEMP_TYPES, not MAX_LOCAL_TYPES.
2021-10-20 18:19:38 -04:00
John Hawthorn
42574768a1 Fix ctx_clear_local_types 2021-10-20 18:19:38 -04:00
John Hawthorn
250b97da9b Make ctx_diff aware of mappings 2021-10-20 18:19:38 -04:00
John Hawthorn
6c80150d40 Introduce ctx_{get,set}_opnd_mapping 2021-10-20 18:19:38 -04:00
John Hawthorn
4ea69e5c0b Rename to ctx_upgrade_opnd_type 2021-10-20 18:19:38 -04:00
John Hawthorn
53079ca585 Return if fixnums impossible 2021-10-20 18:19:38 -04:00
Alan Wu
f4f940e5a6 Save PC and SP before accessing globals
These instructions are marked as not leaf in insns.def, which indicate
that they could raise exceptions and/or call Ruby methods.
2021-10-20 18:19:38 -04:00
eileencodes
b91078ea74 Add setglobal to yjit
Adds yjit support for setting global variables.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
Co-authored-by: John Hawthorn <john@hawthorn.email>
2021-10-20 18:19:38 -04:00
Noah Gibbs
dd23e4658b If codeblock is NULL because YJIT is disabled, YJIT.runtime_stats should return Qnil 2021-10-20 18:19:38 -04:00
eileencodes
50029fb127 Add getglobal to yjit
Adds getglobal to yjit and a test for it.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-10-20 18:19:38 -04:00
John Hawthorn
6aa4637272 Fix and uncomment getlocal test
Previously, under the scraper, this would side-exit because it was
returning to a C method. Now that we use the jit_func entrypoint, this
test no longer side-exits.
2021-10-20 18:19:38 -04:00
Maxime Chevalier-Boisvert
1891dcaa9f Add flag so we can easily tell if all stats avail. Comment out broken test. 2021-10-20 18:19:38 -04:00