Commit graph

68 commits

Author SHA1 Message Date
Alan Wu
68b0f69a0d Make a bunch of functions compilation unit local 2021-10-20 18:19:26 -04:00
Alan Wu
5f9beb9b1b Include disassembly in MicroJIT scraper output 2021-10-20 18:19:26 -04:00
Alan Wu
188c54428c MicroJIT: avoid having to invalidate running output code 2021-10-20 18:19:26 -04:00
Alan Wu
9ce9f613b0 Update comment for ujit_compile_insn 2021-10-20 18:19:26 -04:00
Alan Wu
c378c7a7cb MicroJIT: generate less code for CFUNCs
Added UJIT_CHECK_MODE. Set to 1 to double check method dispatch in
generated code.

It's surprising to me that we need to watch both cc and cme. There might
be opportunities to simplify there.
2021-10-20 18:19:26 -04:00
Maxime Chevalier-Boisvert
0c52371c47 Don't create a stack frame for Hash#key? 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
5413d0918b Fix GCC warning 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
81e7091862 Added stack overflow check to MicroJIT CFUNC calls 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
8b8470d098 Added RUBY_VM_CHECK_INTS to CFUNC calls 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
5b6a963b71 Fix compiler warnings 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
b761f5c96f Implemented mechanism for rel32 call 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
809ecfb126 Fixed two CFUNC call bugs thanks to Alan & Aaron! 2021-10-20 18:19:25 -04:00
Alan Wu
c2cb6a6fd3 MicroJIT: Read pointer to call cache from call data
The call cache changes when the call site becomes polymophic and can
result in the generated code falsely assuming cd->cc->cme is not NULL.

Here is a crasher:

    def body(thing)
      thing.strip
    end

    str = ""
    10.times { body(str) }
    body(0) rescue p 'not found'
    body(str)
2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
d49edada2e Fix MicroJIT argument copying for CFUNC calls 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
37e4350e80 Fixed two issues with MicroJIT CFUNC calls 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
35c0768473 First pass at CFUNC calls complete. Not yet functional. 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
ff73762bda Refactor ujit, define named register constants, code cleanup 2021-10-20 18:19:25 -04:00
Alan Wu
6ca360aa47 MicroJIT: switch to example that passes ec as second argument
opt_send_without_block needs it. Ideally we would use this example
only when an instruction in the compiled sequence needs `ec`. We can
worry about that later.
2021-10-20 18:19:25 -04:00
Alan Wu
1ef2887bc1 MicroJIT: Use R9 in generated code for Ruby stack pointer 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
008551decb Commit before merge. 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
a88d6207dd Updated C function call sketch 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
770f3929b3 Remove comment. Commit before rebase. 2021-10-20 18:19:25 -04:00
Alan Wu
93f6ac39f2 MicroJIT: Don't compile trace instructions 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
e677ca4af0 Fixed is-object check in opt_send_without_block 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
7c9fdb5dc9 Check receiver type and klass in MicroJIT 2021-10-20 18:19:25 -04:00
Alan Wu
7650352868 Take the VM lock when recompiling 2021-10-20 18:19:25 -04:00
Alan Wu
8bda11f690 MicroJIT: compile after ten calls 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
ef9eb83cbe Commit before merge 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
2cb376a53f Started refactoring opt_send_without_block with codegen-time checks 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
32a66b99f6 Add system to implement codegen preconditions in JIT 2021-10-20 18:19:25 -04:00
Maxime Chevalier-Boisvert
6f81bd2c76 Added print_ptr() util function for debugging 2021-10-20 18:19:25 -04:00
Alan Wu
3c8a9da7ef Bump executable memory allocation size
We run out it on CI in test-all.
2021-10-20 18:19:24 -04:00
Alan Wu
7e400ddc79 Try to fix Windows build 2021-10-20 18:19:24 -04:00
Alan Wu
805f49630d Fix MicroJIT's putobject against GC copmaction 2021-10-20 18:19:24 -04:00
Alan Wu
7d1546ece5 Try to fix Windows build 2021-10-20 18:19:24 -04:00
Alan Wu
a3e58f4df8 Compile with MicroJIT disabled when scrape fails
This is just so we can build successfully on -O0 and other cases that
are not supported by the code scraper.
2021-10-20 18:19:24 -04:00
Maxime Chevalier-Boisvert
e3cd43e2bc Implemented opt_minus in MicroJIT 2021-10-20 18:19:24 -04:00
Maxime Chevalier-Boisvert
851ea46351 Added member_opnd() convenience macro 2021-10-20 18:19:24 -04:00
Aaron Patterson
d7f012666d Partially implement opt_send_without_block
It will read and check the inline cache now, but we need to actually
call the method.

Co-Authored-By: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
2021-10-20 18:19:24 -04:00
Maxime Chevalier-Boisvert
2c866ce8f0 Check if outlined code block has enough space too 2021-10-20 18:19:24 -04:00
Alan Wu
e8c914c250 Implement the --disable-ujit command line option 2021-10-20 18:19:24 -04:00
Maxime Chevalier-Boisvert
e0c5d4ecd9 Implemented side-exits to interpreter. setlocal_WC_0 2021-10-20 18:19:24 -04:00
Maxime Chevalier-Boisvert
4d72b9a2f7 Start implementing setlocal_wc0 2021-10-20 18:19:24 -04:00
Alan Wu
3d87eadf16 Refactor ujit_examples.h generator. Remove dwarfdump dependency 2021-10-20 18:19:24 -04:00
Alan Wu
2eaf55fcf1 Update PC in memory when exiting jitted code
Without this, the allocation tracker was inaccurate and
was causing a failure in `test/objspace/test_objspace.rb`.
2021-10-20 18:19:23 -04:00
Alan Wu
86c438d129 Revert "Add workaround for inserting into addr2insn mapping"
This reverts commit 6b765b7ca0.
It made things much slower and didn't fix the crash.
2021-10-20 18:19:23 -04:00
Alan Wu
5bcba2a5ee Add workaround for inserting into addr2insn mapping 2021-10-20 18:19:23 -04:00
Maxime Chevalier-Boisvert
304adba717 Add location hint to code block mmap call 2021-10-20 18:19:23 -04:00
Maxime Chevalier-Boisvert
c20066b24c Added method to align code block write position 2021-10-20 18:19:23 -04:00
Maxime Chevalier-Boisvert
30c4237b06 Fixed bug with ctx_stack_pop. Implemented dup bytecode. 2021-10-20 18:19:23 -04:00