aboutsummaryrefslogtreecommitdiffstats
path: root/mjit_compile.c
Commit message (Collapse)AuthorAgeFilesLines
* Add a proper cast to pass JIT tests on mswin.Koichi Sasada2019-11-211-1/+1
| | | | https://ci.appveyor.com/project/ruby/ruby/builds/29001248/job/ye80bsrmewdgw294
* support builtin features with Ruby and C.Koichi Sasada2019-11-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support loading builtin features written in Ruby, which implement with C builtin functions. [Feature #16254] Several features: (1) Load .rb file at boottime with native binary. Now, prelude.rb is loaded at boottime. However, this file is contained into the interpreter as a text format and we need to compile it. This patch contains a feature to load from binary format. (2) __builtin_func() in Ruby call func() written in C. In Ruby file, we can write `__builtin_func()` like method call. However this is not a method call, but special syntax to call a function `func()` written in C. C functions should be defined in a file (same compile unit) which load this .rb file. Functions (`func` in above example) should be defined with (a) 1st parameter: rb_execution_context_t *ec (b) rest parameters (0 to 15). (c) VALUE return type. This is very similar requirements for functions used by rb_define_method(), however `rb_execution_context_t *ec` is new requirement. (3) automatic C code generation from .rb files. tool/mk_builtin_loader.rb creates a C code to load .rb files needed by miniruby and ruby command. This script is run by BASERUBY, so *.rb should be written in BASERUBY compatbile syntax. This script load a .rb file and find all of __builtin_ prefix method calls, and generate a part of C code to export functions. tool/mk_builtin_binary.rb creates a C code which contains binary compiled Ruby files needed by ruby command.
* extend rb_call_cache卜部昌平2019-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | Prior to this changeset, majority of inline cache mishits resulted into the same method entry when rb_callable_method_entry() resolves a method search. Let's not call the function at the first place on such situations. In doing so we extend the struct rb_call_cache from 44 bytes (in case of 64 bit machine) to 64 bytes, and fill the gap with secondary class serial(s). Call cache's class serials now behavies as a LRU cache. Calculating ------------------------------------- ours 2.7 2.6 vm2_poly_same_method 2.339M 1.744M 1.369M i/s - 6.000M times in 2.565086s 3.441329s 4.381386s Comparison: vm2_poly_same_method ours: 2339103.0 i/s 2.7: 1743512.3 i/s - 1.34x slower 2.6: 1369429.8 i/s - 1.71x slower
* Combine call info and cache to speed up method invocationAlan Wu2019-10-241-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | To perform a regular method call, the VM needs two structs, `rb_call_info` and `rb_call_cache`. At the moment, we allocate these two structures in separate buffers. In the worst case, the CPU needs to read 4 cache lines to complete a method call. Putting the two structures together reduces the maximum number of cache line reads to 2. Combining the structures also saves 8 bytes per call site as the current layout uses separate two pointers for the call info and the call cache. This saves about 2 MiB on Discourse. This change improves the Optcarrot benchmark at least 3%. For more details, see attached bugs.ruby-lang.org ticket. Complications: - A new instruction attribute `comptime_sp_inc` is introduced to calculate SP increase at compile time without using call caches. At compile time, a `TS_CALLDATA` operand points to a call info struct, but at runtime, the same operand points to a call data struct. Instruction that explicitly define `sp_inc` also need to define `comptime_sp_inc`. - MJIT code for copying call cache becomes slightly more complicated. - This changes the bytecode format, which might break existing tools. [Misc #16258]
* Just disable inlining with local varaible for nowTakashi Kokubun2019-07-031-0/+13
| | | | | | | | | | | This partially reverts commit 712a66b0741605f5b2db670a292b9bb352f8a716. The previous fix made CI strange like: http://ci.rvm.jp/results/trunk-vm-asserts@silicon-docker/2124178 Let me just downgrade the behavior for now and deal with it later. [Bug #15971]
* Revert "Try dropping const qualifier to suppress msiwn warning"k0kubun2019-04-211-1/+1
| | | | | | | | This reverts commit b023c1cc07b2fd6e201bf3aeb4a1df9af3854888. in favor of r67666. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Get rid of warinings of VCusa2019-04-211-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Try dropping const qualifier to suppress msiwn warningk0kubun2019-04-211-1/+1
| | | | | | https://ci.appveyor.com/project/ruby/ruby/builds/23995093/job/qo728n1uorepkx16 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Recompile without method inliningk0kubun2019-04-161-7/+11
| | | | | | if cancel happens in an inlined method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Introduce frame-omitted method inliningk0kubun2019-04-161-18/+109
| | | | | | for ISeq including only leaf and no-handles_sp insns except leaf. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Implement single-level basic method inlining in JITk0kubun2019-04-161-21/+89
| | | | | | "Basic" means it does not omit a call frame. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Carve out mjit_compile_bodyk0kubun2019-04-151-14/+21
| | | | | | | | This refactoring is needed for implementing inlining later. I've had this since long ago and it has conflicted sometimes. So let me just commit this now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Share optimization cancel handlersk0kubun2019-04-141-0/+13
| | | | | | | | | | | | | | | | | | | | | | | $ benchmark-driver benchmark.yml --rbenv='before --jit;after --jit' -v --output=all --repeat-count=12 before --jit: ruby 2.7.0dev (2019-04-14 trunk 67549) +JIT [x86_64-linux] after --jit: ruby 2.7.0dev (2019-04-14 trunk 67549) +JIT [x86_64-linux] last_commit=Share optimization cancel handlers Calculating ------------------------------------- before --jit after --jit Optcarrot Lan_Master.nes 69.55360655447375 74.15329176797863 fps 73.74545038318978 79.60903046141544 75.85637357897092 82.00930075612054 77.10594124022951 82.56228187301674 78.67350527368366 83.37512204205953 79.97235230767613 83.41521927993719 81.03050342478066 84.20227901852776 81.61308297895094 84.73733526226468 82.06805141753206 85.27884867863791 82.46493179193394 85.36558922650367 83.85259832896313 85.39993587223481 84.02325292922997 85.63649355214602 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Unify comment styles across MJIT sourcesk0kubun2019-04-141-27/+27
| | | | | | | | | | | | I'm writing `//` comments in newer MJIT code after C99 enablement (because I write 1-line comments more often than multi-line comments and `//` requires fewer chars on 1-line) and then they are mixed with `/* */` now. For consistency and to avoid the conversion in future changes, let me finish the rewrite in MJIT-related code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Recompile JIT-ed code without optimizationk0kubun2019-04-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | based on inline cache when JIT cancel happens by that. This feature was in the original MJIT implementation by Vladimir, but on merging MJIT to Ruby it was removed for simplification. This commit adds the functionality again for the following benchmark: https://github.com/benchmark-driver/misc/blob/52f05781f65467baf895bf6ba79d172c9b0826fd/concurrent-map/bench.rb (shown float is duration seconds. shorter is better) * Before ``` $ INHERIT=0 ruby -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) [x86_64-linux] -- 1.6507579649914987 $ INHERIT=0 ruby -v --jit bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) +JIT [x86_64-linux] -- 1.5091587850474752 $ INHERIT=1 ruby -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) [x86_64-linux] -- 1.6124781150138006 $ INHERIT=1 ruby --jit -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) +JIT [x86_64-linux] -- 1.7495657080435194 # <-- this ``` * After ``` $ INHERIT=0 ruby -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) [x86_64-linux] last_commit=Recompile JIT-ed code without optimization -- 1.653559010999743 $ INHERIT=0 ruby --jit -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) +JIT [x86_64-linux] last_commit=Recompile JIT-ed code without optimization -- 1.4738391840364784 $ INHERIT=1 ruby -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) [x86_64-linux] last_commit=Recompile JIT-ed code without optimization -- 1.645227018976584 $ INHERIT=1 ruby --jit -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) +JIT [x86_64-linux] last_commit=Recompile JIT-ed code without optimization -- 1.523708809982054 # <-- this ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add debug counters for MJIT cancelk0kubun2019-03-291-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prefer using vm_base_ptr rather than cfp->bpk0kubun2019-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in MJIT implementation. This allows us to drop cfp->bp by just modifying vm_base_ptr in the future. No performance impact: $ benchmark-driver benchmark.yml --rbenv='before::before --disable-gems --jit;bp_::after --disable-gems --jit;vm_env_ptr::ruby-svn --disable-gems --jit' -v --output=all --repeat-count=12 before: ruby 2.7.0dev (2019-03-24 trunk 67341) +JIT [x86_64-linux] bp_: ruby 2.7.0dev (2019-03-24 trunk 67342) +JIT [x86_64-linux] vm_env_ptr: ruby 2.7.0dev (2019-03-25 trunk 67343) +JIT [x86_64-linux] last_commit=Prefer using vm_base_ptr rather than cfp->bp Calculating ------------------------------------- before bp_ vm_env_ptr Optcarrot Lan_Master.nes 77.15059205092646 70.18873044267853 69.62171387083328 fps 78.75767783870441 77.49867689173411 75.43496867709587 79.60102690369321 77.78037687683523 79.36688927929428 80.25144236638835 78.74729849101701 80.42363742291455 82.22375417165489 80.44265482494045 80.90287243299306 82.29166786292619 80.51740049420938 81.81153053252902 83.35386925305345 80.91054205210609 81.93562989125176 83.39770634366975 81.34550754145043 82.24544621470430 83.88523450309972 81.60698516017347 82.76801860263230 84.17553130135879 82.69615943446324 83.02530407910871 84.42132328119858 83.00969158037691 83.19968539409922 84.60731429793329 83.32703363300098 83.81352746019631 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use cfp->bp more.ko12019-03-251-1/+1
| | | | | | | | | | | | | | cfp->bp was (re-)introduced by Kokubun san, but VM doesn't use it because I (ko1) want to remove it in a future. But using it make leave instruction fast because of sp consisntency check. So now VM uses cfp->bp. To use cfp->bp, I checked the value and I found that it is not a "initial value of sp" but a "initial value of ep". Fix this problem and fix all bp references (this is why bp is renamed to bp_). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Check argument_arity_error condition in inlinable_iseq_pk0kubun2019-03-211-1/+2
| | | | | | | to avoid inlining a method call when it becomes argument_arity_error, fixing a potential bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Share vm_call_iseq_optimizable_p to reduce copy-pastek0kubun2019-03-211-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use designated initializers for compile_statusk0kubun2019-03-181-15/+10
| | | | | | | to make it easier to understand what values are grouped. Just cosmetic changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use alloca for stack_size_for_pos as wellk0kubun2019-03-181-5/+1
| | | | | | to eliminate necessity of error check and `free` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use alloca again instead of malloc and freek0kubun2019-03-181-4/+12
| | | | | | | | by changing interface of `mjit_copy_cache_from_main_thread`. This is also fixing deadlock introduced by r67299. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Resurrect r67287 and r67288k0kubun2019-03-181-3/+9
| | | | | | | | | I noticed that r67287 was illegal because memory allocated by `alloca` was used after the stack is expired. So I just replaced that with `malloc` and `free` for now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Request inline cache values from mjit_compile"k0kubun2019-03-181-7/+3
| | | | | | | | | | | | This reverts commit 4161674b2fbea6bdd01783ac5d3b39d88db22972. Revert "Eliminate mjit_copy_job_t reference from mjit_worker" This reverts commit d86a1aa045959dfbf5cd472eae0d043180259727. Reverting them because of CI failures git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Request inline cache values from mjit_compilek0kubun2019-03-171-3/+7
| | | | | | | | | | rather than preparing beforehand. By having this change, implementing inlining by calling `mjit_copy_cache_from_main_thread` for inlined methods was made possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: use boolean type for boolean variablesk0kubun2019-01-101-22/+22
| | | | | | | | | | and functions to clarify the intention and make sure it's not used in a surprising way (like using 2, 3, ... other than 0, 1 even while it seems to be a boolean). This is a retry of r66775. It included some typos... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "mjit.c: use boolean type for boolean variables"k0kubun2019-01-101-22/+22
| | | | | | | | This reverts commit bb1a1aeab0f2a5fe437c89b841a887ba56653453. We hit something on ci.rvm.jp, reverting until investigation is done. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: use boolean type for boolean variablesk0kubun2019-01-101-22/+22
| | | | | | | | and functions to clarify the intention and make sure it's not used in a surprising way (like using 2, 3, ... other than 0, 1 even while it seems to be a boolean). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: copy call cache values to MJIT workerk0kubun2018-10-211-2/+4
| | | | | | | | | | | | | | | | | | | | same as r65275 but for call cache. === Optcarrot Benchmark === $ benchmark-driver benchmark.yml --rbenv 'before::before --disable-gems --jit;after::after --disable-gems --jit' -v --repeat-count 24 before: ruby 2.6.0dev (2018-10-21 trunk 65277) +JIT [x86_64-linux] after: ruby 2.6.0dev (2018-10-21 trunk 65277) +JIT [x86_64-linux] last_commit=mjit.c: copy call cache values to MJIT worker Calculating ------------------------------------- before after Optcarrot Lan_Master.nes 85.372 85.359 fps Comparison: Optcarrot Lan_Master.nes before: 85.4 fps after: 85.4 fps - 1.00x slower git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: copy inline cache values to MJIT workerk0kubun2018-10-211-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | on VM_CHECK_INTS. Letting MJIT worker directly see inline cache which may be being updated could result in inconsistent IC index and serial. mjit_worker.c: request the copy job after dequeue, and receive the result synchronously. tool/ruby_vm/views/_mjit_compile_ivar.erb: use the copied IC mjit_compile.c: change the interface to pass is_entries mjit.h: ditto === Optcarrot Benchmark === Thankfully this didn't have major performance regression. $ benchmark-driver benchmark.yml --rbenv 'before::before --disable-gems --jit;after::after --disable-gems --jit' -v --repeat-count 24 before: ruby 2.6.0dev (2018-10-21 trunk 65263) +JIT [x86_64-linux] after: ruby 2.6.0dev (2018-10-21 trunk 65263) +JIT [x86_64-linux] last_commit=mjit.c: copy inline cache values to MJIT worker Calculating ------------------------------------- before after Optcarrot Lan_Master.nes 85.421 85.454 fps Comparison: Optcarrot Lan_Master.nes after: 85.5 fps before: 85.4 fps - 1.00x slower git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * append newline at EOF.svn2018-10-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add disabling MJIT features option.ko12018-10-201-0/+5
| | | | | | | | | | | | | | | | | | | | * configure.ac: introduce new configure option `--enable-mjit` and `--disable-mjit`. Default is "enable". `--disable-mjit` disables all of MJIT features so that `ruby --jit` can't enable MJIT. This option affect a macro `USE_MJIT`. This change remove `--enable/disable-install-mjit-header` option. * Makefile.in: introduce the `ENABLE_MJIT` variable. * common.mk: use `ENABLE_MJIT` option. * internal.h: respect `USE_MJIT`. Same as other *.c, *.h. * test/ruby/test_jit.rb: check `ENABLE_MJIT` key of rbconfg.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_opts.h: share USE_IC_FOR_IVAR as OPT_IC_FOR_IVARk0kubun2018-10-141-5/+0
| | | | | | | | | | with mjit_compile.c (tool/ruby_vm/views/_mjit_compile_getivar.erb). mjit_compile.c: ditto tool/ruby_vm/views/_mjit_compile_getivar.erb: ditto vm_opts.h: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* _mjit_compile_getivar.erb: optimize IC-hit getivark0kubun2018-10-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | by inlining index (and serial to invalidate that) and simplifying the branch by using JIT cancellation. mjit_compile.inc.erb: use the above file mjit_compile.c: copy USE_IC_FOR_IVAR definition. will move this to another shared file later. common.mk: add new dependency test/ruby/test_jit.rb: cover this case === Optcarrot benchmark === ``` $ benchmark-driver benchmark.yml --rbenv '2.0.0::2.0.0-p648;before::before --disable-gems;before+JIT::before --disable-gems --jit;after::after --disable-gems;after+JIT::after --disable-gems --jit' -v --repeat-count 24 2.0.0: ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux] before: ruby 2.6.0dev (2018-10-14 trunk 65072) [x86_64-linux] before+JIT: ruby 2.6.0dev (2018-10-14 trunk 65072) +JIT [x86_64-linux] after: ruby 2.6.0dev (2018-10-14 trunk 65072) [x86_64-linux] last_commit=_mjit_compile_getivar.erb: optimize IC-hit getivar after+JIT: ruby 2.6.0dev (2018-10-14 trunk 65072) +JIT [x86_64-linux] last_commit=_mjit_compile_getivar.erb: optimize IC-hit getivar Calculating ------------------------------------- 2.0.0 before before+JIT after after+JIT Optcarrot Lan_Master.nes 36.065 53.896 71.565 53.856 84.747 fps Comparison: Optcarrot Lan_Master.nes after+JIT: 84.7 fps before+JIT: 71.6 fps - 1.18x slower before: 53.9 fps - 1.57x slower after: 53.9 fps - 1.57x slower 2.0.0: 36.1 fps - 2.35x slower ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-09-301-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_compile.c: improve assertion messagek0kubun2018-09-301-7/+7
| | | | | | | | | intentionally inserting tab to this line to test svn bot. Also expanding the all tabs in this file, since this file does not exist in old versions and so there's no risk of conflict on backport. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.h: rename CI_SET_FASTPATH to CC_SET_FASTPATHk0kubun2018-09-181-2/+2
| | | | | | | | | | because it's actually setting fastpath to cc instead of ci since r51903. vm_insnhelper.c: ditto mjit_compile.c: ditto tool/ruby_vm/views/_mjit_compile_send.erb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: don't use ruby_strdupk0kubun2018-08-111-1/+1
| | | | | | | | on MJIT worker. That may trigger GC. And handled strdup failure instead. mjit_compile.c: update comment about GC git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: exclude mjit_valid_class_serial_pk0kubun2018-08-111-0/+1
| | | | | | | | from mjit.c because it's executed only on MJIT worker thread. Instead of that, `valid_class_serials` is shared with mjit_ prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: carve out worker-related codek0kubun2018-08-111-0/+4
| | | | | | | | | | | | | | The motivation of this change is to make sure rb_funcall or GC-related functions are not called on worker-related code. Currently such functions are used in some places and I believe it's partly because it's hard to identify which part is called on MJIT worker thread. Now, mjit.c is safe to use them but we know we need to safely deal with mjit_compile.c, mjit_worker.c and mjit_internal.h. mjit_compile.c: update the comment about it git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* _mjit_compile_send.erb: refactor to share vm_call_iseq_setup_normalk0kubun2018-08-111-1/+1
| | | | | | | | | | | implementation. This had no major performance impact by effort to keep them inlined. vm_insnhelper.c: ditto mjit_compile.c: just update the comment about opt_pc=0 assumption git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: handle memory allocation failurek0kubun2018-07-241-0/+2
| | | | | | | | | | | | | which was missing in r64033. Prior to r64033, memory allocation failure had been checked by TRY_WITH_GC and handled by rb_memerror. But calling rb_memerror on MJIT worker is problematic since it does EC_JUMP_TAG in the end. Threads except Ruby's main thread must not use it. mjit_compile.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: prevent GC on MJIT workerk0kubun2018-07-241-2/+2
| | | | | | | | | | mjit_compile.c: ditto. REALLOC_N, ALLOC_N and xmalloc trigger GC but it's not expected. Other allocation calls in mjit.c are executed on Ruby's main thread and thus fine. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_compile.c: reduce sp motion on JITk0kubun2018-07-191-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This retries r62655, which was reverted at r63863 for r63763. tool/ruby_vm/views/_mjit_compile_insn.erb: revert the revert. tool/ruby_vm/views/_mjit_compile_insn_body.erb: ditto. tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb: ditto. tool/ruby_vm/views/_mjit_compile_send.erb: ditto. tool/ruby_vm/views/mjit_compile.inc.erb: ditto. tool/ruby_vm/views/_insn_entry.erb: revert half of r63763. The commit was originally reverted since changing pc motion was bad for tracing, but changing sp motion was totally fine. For JIT, I wanna resurrect the sp motion change in r62051. tool/ruby_vm/models/bare_instructions.rb: ditto. insns.def: ditto. vm_insnhelper.c: ditto. vm_insnhelper.h: ditto. * benchmark $ benchmark-driver benchmark.yml --rbenv 'before;after;before --jit;after --jit' --repeat-count 12 -v before: ruby 2.6.0dev (2018-07-19 trunk 63998) [x86_64-linux] after: ruby 2.6.0dev (2018-07-19 add-sp 63998) [x86_64-linux] last_commit=mjit_compile.c: reduce sp motion on JIT before --jit: ruby 2.6.0dev (2018-07-19 trunk 63998) +JIT [x86_64-linux] after --jit: ruby 2.6.0dev (2018-07-19 add-sp 63998) +JIT [x86_64-linux] last_commit=mjit_compile.c: reduce sp motion on JIT Calculating ------------------------------------- before after before --jit after --jit Optcarrot Lan_Master.nes 51.354 50.238 70.010 72.139 fps Comparison: Optcarrot Lan_Master.nes after --jit: 72.1 fps before --jit: 70.0 fps - 1.03x slower before: 51.4 fps - 1.40x slower after: 50.2 fps - 1.44x slower git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r63988k0kubun2018-07-171-16/+1
| | | | | | | | Due to trunk-mjit CI failures: http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1130097 http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1130196 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_compile.c: resurrect local variable stackk0kubun2018-07-171-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This optimization was reverted on r63863, but this commit resurrects the optimization to skip some sp motions on JIT execution. tool/ruby_vm/views/_mjit_compile_insn_body.erb: ditto tool/ruby_vm/views/_mjit_compile_insn.erb: ditto insns.def: resurrect handles_frame as handles_stack, which was deleted on r63763. tool/ruby_vm/models/bare_instructions.rb: ditto vm_insnhelper.c: prevent moving sp outside insns.def to allow modifying it by JIT. * Optcarrot benchmark $ benchmark-driver benchmark.yml --rbenv 'before --jit;after --jit' --repeat-count 12 -v before --jit: ruby 2.6.0dev (2018-07-17 trunk 63987) +JIT [x86_64-linux] after --jit: ruby 2.6.0dev (2018-07-17 local-stack 63987) +JIT [x86_64-linux] last_commit=mjit_compile.c: resurrect local variable stack Calculating ------------------------------------- before --jit after --jit Optcarrot Lan_Master.nes 70.518 72.144 fps Comparison: Optcarrot Lan_Master.nes after --jit: 72.1 fps before --jit: 70.5 fps - 1.02x slower git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r62655 for r63763k0kubun2018-07-051-16/+1
| | | | | | | | | | | | | r63655 was tightly coupled to handle_frames and some assumptions seems to have been broken by r63763. To partially resolve Bug#14892, this reverts the optimization for now. I want to make MJIT CI happy first and then I'll probably retry r63655 by partially reverting r63763 for sp changes. The skipped test is not fixed yet. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_compile.c: drop catch table handlingk0kubun2018-05-291-6/+2
| | | | | | | | | | The loop for `vm_exce_handle_exception` doesn't trigger `mjit_exec`, so I don't think this code is no longer needed. This was needed in development of original version of this JIT, but it seems not needed from the beginning (r62189) at Ruby repository. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* _mjit_compile_send.erb: revert r63350k0kubun2018-05-091-2/+0
| | | | | | | | | Revert "_mjit_compile_send.erb: inline recursive call" I reverted r63360 in r63379, but the errors were reproductive from r63350. So I need to revert this. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e