Commit graph

268 commits

Author SHA1 Message Date
Maxime Chevalier-Boisvert
0db85218aa Avoid interrupt checks for forward branches (#41) 2021-10-20 18:19:35 -04:00
Maxime Chevalier-Boisvert
54fe43b45c Implement defined bytecode (#39) 2021-10-20 18:19:35 -04:00
Maxime Chevalier-Boisvert
3677b233dd Implement opt_nil_p and opt_empty_b by delegating to send (#35) 2021-10-20 18:19:35 -04:00
Maxime Chevalier-Boisvert
d6412126bc Implement setivar with a plain old function call (#34)
* Implement setivar with a plain old function call

* Remove return
2021-10-20 18:19:35 -04:00
Alan Wu
7eef8f09c0 Implement getblockparamproxy
* Implement getblockparamproxy

* Parallel runner: wait for timeout thread to terminate after killing

Or else the leak cheaker could sees the thread as running and cause test
failures in test-tool.

* Add a comment, use jne

* Comment about where 0x3 comes from
2021-10-20 18:19:35 -04:00
Maxime Chevalier-Boisvert
ce928473d0 Deletate to opt_send_without_block for opt_ltlt (#33) 2021-10-20 18:19:35 -04:00
Maxime Chevalier-Boisvert
0c3842d154 Implement opt_aset as interpreter handler call 2021-10-20 18:19:35 -04:00
Maxime Chevalier-Boisvert
c9feb72b65 Implement opt_mod as call to interpreter function (#29) 2021-10-20 18:19:35 -04:00
Maxime Chevalier-Boisvert
e2c1d69331 Implement opt_eq by calling interpreter function (#28) 2021-10-20 18:19:35 -04:00
Maxime Chevalier-Boisvert
e22657b887 Implement branchnil bytecode (#26) 2021-10-20 18:19:34 -04:00
Alan Wu
0d64f5e8a8 Check for easy-to-handle cases of block param (#24)
In some cases, methods taking block parameters don't require extra
paramter setup. They are fairly popular in railsbench.
2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
e5f8b41786 Implement send with alias method (#23)
* Implement send with alias method

* Add alias_method tests
2021-10-20 18:19:34 -04:00
Alan Wu
0758115d11 Implement send with blocks
* Implement send with blocks

Not that much extra work compared to `opt_send_without_block`.
Moved the stack over flow check because it could've exited after changes
are made to cfp.

* rename oswb counters

* Might as well implement sending block to cfuncs

* Disable sending blocks to cfuncs for now

* Reconstruct interpreter sp before calling into cfuncs

In case the callee cfunc calls a method or delegates to a block.
This also has the side benefit of letting call sites that sometimes are
iseq calls and sometimes cfunc call share the same successor.

* only sync with interpreter sp when passing a block


Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Co-authored-by: Aaron Patterson <aaron.patterson@shopify.com>
2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
59e5f6b83b Implement dupn for n==2 (only case used in RDoc/railsbench) (#20)
* Implement dupn for n==2 (only case used in RDoc/railsbench)

* Implement adjuststack bytecode
2021-10-20 18:19:34 -04:00
Alan Wu
684e84df7c Use rb_ivar_get() for general case of getivar (#17)
* Use rb_ivar_get() for general case of getivar

Pretty straight forward. Buys about 1% coverage on railsbench.

* Update yjit_codegen.c

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
62c1297e24 Implement setn bytecode (#15) 2021-10-20 18:19:34 -04:00
Alan Wu
36134f7d29 Implement calls to methods with simple optional params
* Implement calls to methods with simple optional params

* Remove unnecessary MJIT_STATIC

See comment for MJIT_STATIC. I added it not knowing whether it's
required because the function next to it has it. Don't use it and wait
for problems to come up instead.

* Better naming, some comments

* Count bailing on kw only iseqs

On railsbench:
```
opt_send_without_block exit reasons:
                  bmethod      59729 (27.7%)
         optimized_method      59137 (27.5%)
      iseq_complex_callee      41362 (19.2%)
             alias_method      33346 (15.5%)
      callsite_not_simple      19170 ( 8.9%)
       iseq_only_keywords       1300 ( 0.6%)
                 kw_splat       1299 ( 0.6%)
    cfunc_ruby_array_varg         18 ( 0.0%)
```
2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
96f4f918b0 Implement greedy versioning. Refactor versioning logic. (#10)
* Implement eager versioning. Refactor versioning logic.

* Add --version-limit and --greedy-versioning command-line args
2021-10-20 18:19:34 -04:00
Alan Wu
4c7afa64b4 Make gen_opt_aref() delegate to gen_opt_send_without_block() (#9)
Basically mirroring the interpreter for the general case.
2021-10-20 18:19:34 -04:00
Alan Wu
f1b11fa454 Comment edits 2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
3e80104024 Aesthetic changes and add missing counter 2021-10-20 18:19:34 -04:00
Alan Wu
8106a95efb English 2021-10-20 18:19:34 -04:00
Alan Wu
10c0275b11 Use jmp with memory operand for smaller code size 2021-10-20 18:19:34 -04:00
Alan Wu
1610dc0864 YJIT: use a context-free landing pad to optimize leave
This allows gen_leave to always do an indirect to cfp->jit_return.
2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
9bd779cbf9 Don't check if value is immediate if context has type info 2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
e66c9f8c62 Remove redundant mov 2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
adbd7ff332 Fix frozen check (use jnz) and move heap object check. 2021-10-20 18:19:34 -04:00
Aaron Patterson
435d7c5088 Improve set instance variable
This commit improves the set ivar implementation.
2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
60496b6666 Pass self type through method calls 2021-10-20 18:19:34 -04:00
Maxime Chevalier-Boisvert
0cc73ca2a9 Malloc branch entries (#112)
* Malloc branch entries

* Add ASM comment for stack overflow check

* WIP

* Fix branch GC code. Add rb_darray_remove_unordered().

* Fix block end_pos after branch rewriting. Remove dst_patched bits.
2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
33c975b813 Merge pull request #114 from Shopify/yjit-dup-comments
YJIT: Avoid adding duplicate code comments
2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
23f88957e6 Switch to 2-comparison heap object check 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
f2530f884e Improve codegen and type tracking in putobject 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
6250506de2 Remove debug prints 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
edaf12def6 Fix local type tracking in getlocal, setlocal. Add test. 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
791f20af6e WIP 2021-10-20 18:19:33 -04:00
Alan Wu
476a3f4be7 Use a insn_opnd instead of a bool 2021-10-20 18:19:33 -04:00
Alan Wu
4442029ec4 move assert. opnd.idx doesn't make sense for OPND_SELF 2021-10-20 18:19:33 -04:00
Alan Wu
4ea2e753f6 YJIT: implement calls to ivar getter methods 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
6164274c76 Re-enable local type tracking, until first call 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
0805cba735 Update yjit_codegen.c 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
2404ff691d Factor our guard_two_fixnums(). Implement opt_or. 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
f6e3f75c2b Introduce concept of YJIT instruction operands 2021-10-20 18:19:33 -04:00
Alan Wu
b626dd7211 YJIT: Fancier opt_getinlinecache
Make sure `opt_getinlinecache` is in a block all on its own, and
invalidate it from the interpreter when `opt_setinlinecache`.
It will recompile with a filled cache the second time around.
This lets YJIT runs well when the IC for constant is cold.
2021-10-20 18:19:33 -04:00
Alan Wu
515fb988fe YJIT: add comments to disassembly
Introduce a new macro `ADD_COMMENT(cb, comment)` that records a comment
for the current write position in the code block.

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Co-authored-by: Aaron Patterson <aaron.patterson@shopify.com>
2021-10-20 18:19:33 -04:00
Alan Wu
7f4b9e8e61 YJIT: make ratio_in_yjit more accurate
Don't count instructions that take exit to the interpreter.
2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
54312d777c Disable local type tracking for now 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
cbbae12a96 Keep track of local types in the context 2021-10-20 18:19:33 -04:00
Maxime Chevalier-Boisvert
c299112fd7 use ctx_stack_push_self() 2021-10-20 18:19:32 -04:00
Maxime Chevalier-Boisvert
aee44e4f2b Part 1 of improved type tracking logic 2021-10-20 18:19:32 -04:00