69650 Commits

Author SHA1 Message Date
Alan Wu
b74d6563a6 Extract yjit_force_iv_index and make it work when object is frozen
In an effort to simplify the logic YJIT generates for accessing instance
variable, YJIT ensures that a given name-to-index mapping exists at
compile time. In the case that the mapping doesn't exist, it was created
by using rb_ivar_set() with Qundef on the sample object we see at
compile time. This hack isn't fine if the sample object happens to be
frozen, in which case YJIT would raise a FrozenError unexpectedly.

To deal with this, make a new function that only reserves the mapping
but doesn't touch the object. This is rb_obj_ensure_iv_index_mapping().
This new function superceeds the functionality of rb_iv_index_tbl_lookup()
so it was removed.

Reported by and includes a test case from John Hawthorn <john@hawthorn.email>

Fixes: GH-282
2021-10-20 18:19:43 -04:00
Maxime Chevalier-Boisvert
2e2430564a Update yjit.md 2021-10-20 18:19:43 -04:00
Alan Wu
adcee68aa0 Doc: remove outdated note about hooking into the interpreter
DAE remember MicroJIT?
2021-10-20 18:19:43 -04:00
Alan Wu
8a9a2d0049 Move test_yjit_asm.sh into misc
Since conventionally scripts don't live at the top level of the repo.
2021-10-20 18:19:43 -04:00
Alan Wu
5906a5a732 Add comments about special runtime routines YJIT calls
When YJIT make calls to routines without reconstructing interpreter
state through jit_prepare_routine_call(), it relies on the routine to
never allocate, raise, and push/pop control frames. Comment about this
on the routines that YJTI calls.

This is probably something we should dynamically verify on debug builds.
It's hard to statically verify this as it requires verifying all
functions in the call tree. Maybe something to look at in the future.
2021-10-20 18:19:43 -04:00
Alan Wu
1e23b1a6c2 Actually, tabs are okay in Makefile 2021-10-20 18:19:43 -04:00
Alan Wu
454fbe1046 Expand tabs 2021-10-20 18:19:43 -04:00
Alan Wu
38f364b8f5 Update dependencies 2021-10-20 18:19:43 -04:00
Noah Gibbs
da305dd23e Match the main-branch location of yjit in inits.c 2021-10-20 18:19:43 -04:00
Alan Wu
40608d0b7b Fix indentation in ruby.c 2021-10-20 18:19:43 -04:00
Alan Wu
95e337f815 Warn when trying to use YJIT in --disable-jit-support builds 2021-10-20 18:19:43 -04:00
Alan Wu
ff863f3818 Show --yjit in help message 2021-10-20 18:19:43 -04:00
Alan Wu
11096da6cc Improve YJIT command line option parsing
Previously, options such as "--yjit123" would enable YJIT. Additionally,
the error message for argument parsing mentioned "--jit-..." instead of
"--yjit-...".
2021-10-20 18:19:43 -04:00
Maxime Chevalier-Boisvert
d11ea2520e Update yjit.md 2021-10-20 18:19:43 -04:00
Alan Wu
de0af4faad Revert "Disable YJIT while running MJIT tests (#62)"
This reverts commit 60f3f25cc421b75b3dbf02fef759c4857bf3ef46.
We don't need to pass --disable-yjit when running MJIT tests anymore
because we are off by default.
2021-10-20 18:19:43 -04:00
Alan Wu
27358b6ee4 Simplify code for YJIT const cache in compile.c
Since opt_getinlinecache and opt_setinlinecache point to the same cache
struct, there is no need to track the index of the get instruction and
then store it on the cache struct later when processing the set
instruction. Setting it when processing the get instruction works just
as well.

This change reduces our diff.
2021-10-20 18:19:43 -04:00
Alan Wu
28632ea7ba Mention YJIT in Capstone autoconf check 2021-10-20 18:19:43 -04:00
Alan Wu
63faab3c36 Minimize diff in existing workflow files 2021-10-20 18:19:43 -04:00
eileencodes
4cad893080 Add String#bytesize
Fixes: https://github.com/Shopify/yjit/issues/258

Co-authored-by: Aaron Patterson tenderlove@ruby-lang.org
2021-10-20 18:19:43 -04:00
Alan Wu
5d2e5218f6 Use env var to turn on YJIT for test-bundled-gems
tool/test-bundled-gems.rb use sub processes for testing bundled gems and
doesn't support RUN_OPTS. We weren't enabling YJIT for these tests.
Use an include config with RUBY_YJIT_ENABLE to turn on YJIT for these
tests.

Note that we only test with the default call threshold in this setup,
which is the same as before YJIT was off by defauft. The
--yjit-call-threshold command line was never passed to the tests.
2021-10-20 18:19:43 -04:00
Alan Wu
ec4a79a746 Remove YJIT CI configs for tests make check runs
"make check" runs "make test-spec" and "make test-all", so they don't
need to be individual elements of the matrix.
2021-10-20 18:19:43 -04:00
Alan Wu
413397b91e Turn on YJIT for repeat-count=2 runs through env var
It wasn't on at all before... Since it's a snowflake "include" matrix
element, might as well test the env var with it.
2021-10-20 18:19:43 -04:00
Alan Wu
27661ee8a3 Turn on YJIT in macOS workflow
It wasn't on at all and the printout of RUBY_DESCRIPTION at the end of
`make check` wasn't saying +YJIT.
2021-10-20 18:19:43 -04:00
Alan Wu
efed45966b Show +YJIT in version string and RUBY_DESCRIPTION
There might be code out there that expect `ruby -v` to print only one
line. Since MJIT shows +JIT in `ruby -v` and RUBY_DESCRIPTION, let's
show +YJIT.

The crash report doesn't show anything about MJIT, so adjust the test.
The "test_ruby_version" test was unaware of RUBY_YJIT_ENABLE and so
was failing when the variable is set and inherited into the children
processes it spawns. Explicitly unset the variable in the test.
2021-10-20 18:19:43 -04:00
Kevin Newton
13261f00fb More simple bootstrap tests for kwargs 2021-10-20 18:19:43 -04:00
Alan Wu
32b5125c5e else if style 2021-10-20 18:19:43 -04:00
Maxime Chevalier-Boisvert
35b37c5873 Update yjit_codegen.c
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2021-10-20 18:19:43 -04:00
Maxime Chevalier-Boisvert
201721b713 Update yjit_codegen.c
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2021-10-20 18:19:43 -04:00
Kevin Newton
56b1b93a0c Feedback, tests, and rebase for kwargs 2021-10-20 18:19:43 -04:00
Kevin Newton
c5acbd0208 Bail out if passing keyword arguments to only positional and/or optional methods 2021-10-20 18:19:43 -04:00
Kevin Newton
06a826b8c8 Set up the callee stack pointer properly taking into account the bits object 2021-10-20 18:19:43 -04:00
Kevin Newton
5759d840c3 Correct for positional required arguments 2021-10-20 18:19:43 -04:00
Kevin Newton
266e12ac22 Push the unspecified_bits_value onto the stack 2021-10-20 18:19:42 -04:00
Kevin Newton
9aed5809e1 Reuse stack swapping logic 2021-10-20 18:19:42 -04:00
Kevin Newton
2c0891be20 Get kwargs reordering working 2021-10-20 18:19:42 -04:00
Kevin Newton
885bb972bf Get kwargs working for all passed in the correct order 2021-10-20 18:19:42 -04:00
Alan Wu
1f25bba7b7 YJIT_STATS instead of RUBY_DEBUG for --yjit-stats in help printout 2021-10-20 18:19:42 -04:00
Alan Wu
d4fae3e390 Say YJIT is disabled by default in ruby --help 2021-10-20 18:19:42 -04:00
Alan Wu
d355bf17ba Style fix in ruby.c 2021-10-20 18:19:42 -04:00
Alan Wu
34f1595405 Enable leaked global tests in YJIT workflows 2021-10-20 18:19:42 -04:00
Alan Wu
99facbc070 Correct workflow name for YJIT Ubuntu 2021-10-20 18:19:42 -04:00
Noah Gibbs
4705db6a37 Try turning off test-bundler-parallel to see if that fixes all the build errors 2021-10-20 18:19:42 -04:00
Noah Gibbs
21e58acef3 Don't enable YJIT by default. More tests on both Ubuntu and MacOS.
Add RUBY_YJIT_ENABLE env var and YJIT_FORCE_ENABLE compile-time constant.
Rename YJIT_STATS to RUBY_YJIT_STATS.
2021-10-20 18:19:42 -04:00
Alan Wu
7c08538aa3 Cleanup diff against upstream. Add comments
I did a `git diff --stat` against upstream and looked at all the files
that are outside of YJIT to come up with these minor changes.
2021-10-20 18:19:42 -04:00
Alan Wu
884b6f3dbb Move YJIT internal macros away from yjit.h. Tweak style
Since this file is exposed to the rest of the codebase and they don't
really need to know about things like PLATFORM_SUPPORTED_P.
2021-10-20 18:19:42 -04:00
Alan Wu
ed723ca76f Remove yjit_backend to help with upstreaming
The new backend isn't used at the moment and adds to our diff against
upstream so remove it for now. We can reverse the removal later with git
history.
2021-10-20 18:19:42 -04:00
Alan Wu
506c037a16 Cleanup iseq.c minimize diff with upstream
Most of these are vestiges of our old setup where we hack into the
interpreter loop.
2021-10-20 18:19:42 -04:00
Alan Wu
735b3a7748 Tweak mjit_exec() to remove YJIT symbol exports
We were exporting a couple of symbols in yjit.h because they could be
used by code generated by MJIT. We don't want MJIT calling into YJIT
code anyways so let's stop exporting them to libruby.so.

Also adjust indentation and comments in mjit_exec().
2021-10-20 18:19:42 -04:00
Alan Wu
b242ea87da Re-enable leaked global check
YJIT should be able to pass this check now.
2021-10-20 18:19:42 -04:00
Alan Wu
f6da559d5b Put YJIT into a single compilation unit
For upstreaming, we want functions we export either prefixed with "rb_"
or made static. Historically we haven't been following this rule, so we
were "leaking" a lot of symbols as `make leak-globals` would tell us.

This change unifies everything YJIT into a single compilation unit,
yjit.o, and makes everything unprefixed static to pass `make leak-globals`.
This manual "unified build" setup is similar to that of vm.o.

Having everything in one compilation unit allows static functions to
be visible across YJIT files and removes the need for declarations in
headers in some cases. Unnecessary declarations were removed.

Other changes of note:
  - switched to MJIT_SYMBOL_EXPORT_BEGIN which indicates stuff as being
    off limits for native extensions
  - the first include of each YJIT file is change to be "internal.h"
  - undefined MAP_STACK before explicitly redefining it since it
    collide's with a definition in system headers. Consider renaming?
2021-10-20 18:19:42 -04:00