aboutsummaryrefslogtreecommitdiffstats
path: root/mjit_worker.c
Commit message (Collapse)AuthorAgeFilesLines
* Suppress warningsKazuhiro NISHIYAMA2020-09-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``` compiling ../mjit.c In file included from ../mjit.c:28: ../mjit_worker.c:1270:33: warning: incompatible pointer to integer conversion passing 'const struct rb_callcache *' to parameter of type 'VALUE' (aka 'unsigned long') [-Wint-conversion] assert(BUILTIN_TYPE(cc) != T_MOVED); ^~ /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert' (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0) ^ ../include/ruby/internal/value_type.h:153:23: note: passing argument to parameter 'obj' here RB_BUILTIN_TYPE(VALUE obj) ^ In file included from ../mjit.c:28: ../mjit_worker.c:1271:33: warning: incompatible pointer to integer conversion passing 'const struct rb_callable_method_entry_struct *' to parameter of type 'VALUE' (aka 'unsigned long') [-Wint-conversion] assert(BUILTIN_TYPE(vm_cc_cme(cc)) != T_MOVED); ^~~~~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert' (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0) ^ ../include/ruby/internal/value_type.h:153:23: note: passing argument to parameter 'obj' here RB_BUILTIN_TYPE(VALUE obj) ^ In file included from ../mjit.c:28: ../mjit_worker.c:1272:50: warning: incompatible pointer to integer conversion passing 'const struct rb_callcache *' to parameter of type 'VALUE' (aka 'unsigned long') [-Wint-conversion] assert(!rb_objspace_garbage_object_p(cc)); ^~ /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert' (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0) ^ ../gc.h:128:40: note: passing argument to parameter 'obj' here int rb_objspace_garbage_object_p(VALUE obj); ^ In file included from ../mjit.c:28: ../mjit_worker.c:1273:50: warning: incompatible pointer to integer conversion passing 'const struct rb_callable_method_entry_struct *' to parameter of type 'VALUE' (aka 'unsigned long') [-Wint-conversion] assert(!rb_objspace_garbage_object_p(vm_cc_cme(cc))); ^~~~~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert' (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0) ^ ../gc.h:128:40: note: passing argument to parameter 'obj' here int rb_objspace_garbage_object_p(VALUE obj); ^ 4 warnings generated. ```
* Add assertions when inline caches are copied to MJITAaron Patterson2020-09-181-0/+11
| | | | | | This is a temporary commit to try to find a GC issue. It seems like mjit is pointing at a moved address in the call cache. I want to assert that they aren't TMOVED or garbage objects at the time they get copied
* sed -i s/RUBY3/RBIMPL/g卜部昌平2020-05-111-1/+1
| | | | | Devs do not love "3". The only exception is RUBY3_KEYWORDS in parse.y, which seems unrelated to our interests.
* mjit_worker.c: compile_compact_jit_code is not used on mingwNobuyoshi Nakada2020-05-091-2/+10
|
* Revert 0776198486 for Solaris debugTakashi Kokubun2020-05-031-5/+1
| | | | | | | | For some reason 0776198486 didn't fail https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20200503T230004Z.log.html.gz even while it was before 9aa5fe1bf8. Anyway, there's no need to keep the change anymore.
* Test no .dSYM on macOSTakashi Kokubun2020-05-031-1/+2
| | | | I think 9aa5fe1bf89db8cd215b24d8ddfb668714681b83 helps this issue too.
* Split compile and link for MinGW supportTakashi Kokubun2020-05-031-13/+28
| | | | | | | | MinGW test_jit fails with no error message. Perhaps linker flags should not be passed when compilation is happening. Anyway splitting these stages doesn't matter for performance. So let me just split it to fix the issue. Probably this helps Solaris's issue too.
* Debug Solaris's MJIT failureTakashi Kokubun2020-05-031-1/+5
| | | | | | using -Winvalid-pch https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20200501T170004Z.fail.html.gz
* Support cc_added_args againTakashi Kokubun2020-05-031-1/+1
| | | | This support was accidentally removed in 818d6d33368a396d9cd3d1a34a84015a9e76c5c8.
* Avoid infinite times of JIT compactionTakashi Kokubun2020-05-021-3/+9
| | | | | | | It's to avoid memory leak for actual usage (because they don't get unloaded properly), but also for fixing CI timed out due to JIT compaction taking too long time on --jit-wait (which runs every time) http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2911601
* Stop generating MJIT_PCH include guardTakashi Kokubun2020-05-011-0/+4
| | | | | | | to fix https://ci.appveyor.com/project/ruby/ruby/builds/32577700/job/yh61rom35wt2uv39 It was for JIT compaction, and we don't support it on mswin.
* c_file_access_mode should be defined for WindowsTakashi Kokubun2020-05-011-8/+11
| | | | | | as well. And also unit->c_file doesn't exist in mswin. https://github.com/ruby/ruby/runs/635915704
* Deduplicate functions in compacted JIT codeTakashi Kokubun2020-05-011-76/+77
| | | | | | | | | | | | | | to improve code locality. Using benchmark-driver/sinatra with 100 methods JIT-ed, [Before] 12149.97 rps 1.3M /tmp/_ruby_mjit_p31171u145.so [After] 12818.83 rps 260K /tmp/_ruby_mjit_p32155u145.so (VM is 13714.89 rps)
* Include unit id in a function name of an inlined methodTakashi Kokubun2020-04-301-1/+1
| | | | | I'm trying to make it possible to include all JIT-ed code in a single C file. This is needed to guarantee uniqueness of all function names
* Do not stop the world during JIT compactionTakashi Kokubun2020-04-301-8/+10
| | | | | | | | | | Running C compiler for JIT compaction inside a critical section may lock main thread for a long time when it triggers GC. As I'm planning to increase this duration a bit, I'd like to make sure this doesn't stop the world. For now, I chose to give up unloading units when it's during JIT compaction, assuming other calls may unload them later.
* mjit_worker: __GNUC__ is too lax卜部昌平2020-04-101-1/+1
| | | | Namely icc defines __GNUC__, but doesn't have -Wdeprecated-declarations
* Get rid of bogus warning by VCNobuyoshi Nakada2020-03-171-1/+2
| | | | | | | | | ``` c:\projects\ruby\mjit_worker.c(1219) : warning C4090: 'function' : different 'const' qualifiers ``` It seems confused by passing "pointer to pointer to const object", not "pointer to const object".
* Use a human-readable funcname with --jit-debugTakashi Kokubun2020-03-141-4/+39
| | | | | | | | | | | | | | | | | | | | | | | | | for perf output like: Samples: 100K of event 'cycles:ppp', Event count (approx.): 1007750000 Children Self Command Shared Object Symbol + 81.58% 1.47% ruby ruby [.] rb_vm_exec + 81.06% 7.61% ruby ruby [.] vm_exec_core + 80.16% 0.00% ruby ruby [.] vm_sendish (inlined) + 75.03% 0.00% ruby ruby [.] mjit_exec (inlined) + 74.37% 0.00% ruby ruby [.] mjit_exec (inlined) + 73.42% 0.22% ruby _ruby_mjit_p11277u42.so [.] _mjit42_rack_method_override_rb_call + 73.25% 0.10% ruby _ruby_mjit_p11277u41.so [.] _mjit41_sinatra_show_exceptions_rb_call + 73.19% 0.22% ruby _ruby_mjit_p11277u44.so [.] _mjit44_rack_head_rb_call + 73.03% 0.15% ruby _ruby_mjit_p11277u45.so [.] _mjit45_sinatra_base_rb_call + 72.87% 0.26% ruby _ruby_mjit_p11277u49.so [.] _mjit49_rack_logger_rb_call + 70.56% 0.11% ruby _ruby_mjit_p11277u40.so [.] _mjit40_sinatra_base_rb_call + 68.70% 0.11% ruby _ruby_mjit_p11277u39.so [.] _mjit39_sinatra_base_rb_call + 68.39% 0.29% ruby _ruby_mjit_p11277u56.so [.] _mjit56_rack_protection_frame_options_rb_call + 67.89% 0.18% ruby _ruby_mjit_p11277u37.so [.] _mjit37_sinatra_base_rb_block_in_call + 67.04% 0.16% ruby _ruby_mjit_p11277u34.so [.] _mjit34_sinatra_base_rb_synchronize Reverting deb1c7b97d, fixing `sprint_funcname`'s argument in `compact_all_jit_code`. Also updating common.mk.
* Revert "Use a human-readable funcname with --jit-debug"Takashi Kokubun2020-03-141-39/+4
| | | | | | This reverts commit cecebf55c476ae936f3e880477dfb62149143c46. debugging test failure...
* Use a human-readable funcname with --jit-debugTakashi Kokubun2020-03-141-4/+39
| | | | | | | | | | | | | | | | | | | | | | for perf output like: Samples: 100K of event 'cycles:ppp', Event count (approx.): 1007750000 Children Self Command Shared Object Symbol + 81.58% 1.47% ruby ruby [.] rb_vm_exec + 81.06% 7.61% ruby ruby [.] vm_exec_core + 80.16% 0.00% ruby ruby [.] vm_sendish (inlined) + 75.03% 0.00% ruby ruby [.] mjit_exec (inlined) + 74.37% 0.00% ruby ruby [.] mjit_exec (inlined) + 73.42% 0.22% ruby _ruby_mjit_p11277u42.so [.] _mjit42_rack_method_override_rb_call + 73.25% 0.10% ruby _ruby_mjit_p11277u41.so [.] _mjit41_sinatra_show_exceptions_rb_call + 73.19% 0.22% ruby _ruby_mjit_p11277u44.so [.] _mjit44_rack_head_rb_call + 73.03% 0.15% ruby _ruby_mjit_p11277u45.so [.] _mjit45_sinatra_base_rb_call + 72.87% 0.26% ruby _ruby_mjit_p11277u49.so [.] _mjit49_rack_logger_rb_call + 70.56% 0.11% ruby _ruby_mjit_p11277u40.so [.] _mjit40_sinatra_base_rb_call + 68.70% 0.11% ruby _ruby_mjit_p11277u39.so [.] _mjit39_sinatra_base_rb_call + 68.39% 0.29% ruby _ruby_mjit_p11277u56.so [.] _mjit56_rack_protection_frame_options_rb_call + 67.89% 0.18% ruby _ruby_mjit_p11277u37.so [.] _mjit37_sinatra_base_rb_block_in_call + 67.04% 0.16% ruby _ruby_mjit_p11277u34.so [.] _mjit34_sinatra_base_rb_synchronize
* Avoid referring to an old value of reallocTakashi Kokubun2020-03-121-5/+16
| | | | | | | | OpenBSD RubyCI has failed with SEGV since 4bcd5981e80d3e1852c8723741a0069779464128. https://rubyci.org/logs/rubyci.s3.amazonaws.com/openbsd-current/ruby-master/log/20200312T223005Z.fail.html.gz This was because `status->cc_entries` could be stale after `realloc` call for inlined iseqs.
* Capture inlined iseq's cc entries in root iseq'sTakashi Kokubun2020-03-101-20/+37
| | | | | | | | jit_unit to avoid marking wrong cc entries when inlined iseq is compiled multiple times, resolving the TODO added by daf7c48d88. This obviates pseudo jit_unit in inlined iseq introduced by 7ec2359374 and fixes memory leak of the adhoc unit.
* [win32] suppress false warning by MSVCNobuyoshi Nakada2020-03-041-1/+2
|
* Add missing free on cc_entriesTakashi Kokubun2020-02-261-0/+3
| | | | | Looks like an oversight in b9007b6c548f91e88fd3f2ffa23de740431fa969 and 7ec23593746c8ccabd6c005cc34dde77d564c6c9.
* Internalize rb_mjit_unit definition againTakashi Kokubun2020-02-261-1/+29
| | | | Fixed a TODO in b9007b6c548f91e88fd3f2ffa23de740431fa969
* Explain the situation of inner cc_entries [ci skip]Takashi Kokubun2020-02-251-0/+5
| | | | Add a little more details in 7ec23593746c8ccabd6c005cc34dde77d564c6c9
* Note a situation around xmalloc vs free in MJIT [ci skip]Takashi Kokubun2020-02-251-0/+13
| | | | shared by ko1
* should be initialize jit_unit->cc_entries.Koichi Sasada2020-02-251-1/+1
| | | | | GC can invoke just after allocation of jit_unit->cc_entries so it should be zero-cleared.
* prevent GC from mjit worker.Koichi Sasada2020-02-251-0/+14
| | | | | | | ALLOC_N() can causes GC. Sometimes `mjit_copy_job_handler()` can be called by mjit_worker thread which is not a Ruby thread, so we need to prevent GC in this function. This patch has some issues, but I introduce it to pass the tests.
* Introduce disposable call-cache.Koichi Sasada2020-02-221-29/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch contains several ideas: (1) Disposable inline method cache (IMC) for race-free inline method cache * Making call-cache (CC) as a RVALUE (GC target object) and allocate new CC on cache miss. * This technique allows race-free access from parallel processing elements like RCU. (2) Introduce per-Class method cache (pCMC) * Instead of fixed-size global method cache (GMC), pCMC allows flexible cache size. * Caching CCs reduces CC allocation and allow sharing CC's fast-path between same call-info (CI) call-sites. (3) Invalidate an inline method cache by invalidating corresponding method entries (MEs) * Instead of using class serials, we set "invalidated" flag for method entry itself to represent cache invalidation. * Compare with using class serials, the impact of method modification (add/overwrite/delete) is small. * Updating class serials invalidate all method caches of the class and sub-classes. * Proposed approach only invalidate the method cache of only one ME. See [Feature #16614] for more details.
* Allow specifying arbitrary MJIT flags by --jit-debugTakashi Kokubun2019-12-011-2/+4
| | | | | | | | This is a secret feature for me. It's only for testing and any behavior with this flag override is unsupported. I needed this because I sometimes want to add debug options but do not want to disable optimizations, for using Linux perf.
* Eliminate the possibility to leave freed ISeqTakashi Kokubun2019-10-131-3/+3
| | | | | | | in active_units Hoping to fix: http://ci.rvm.jp/results/trunk-mjit@silicon-docker/2311375
* Delay the free until we stop referring to a unitTakashi Kokubun2019-10-131-1/+3
| | | | | `if (unit->iseq)` might have referred to a freed unit. Therefore this commit delays its free.
* Remove the quick stop path after convert_unit_to_funcTakashi Kokubun2019-10-131-8/+0
| | | | | | | | | | | | | | Now I'm not exactly sure why I needed to check `stop_worker_p` after `mjit_copy_cache_from_main_thread` of `convert_unit_to_func` in 4161674b2fbea6bdd01783ac5d3b39d88db22972. If it's for avoiding deadlock under `in_gc` condition, we should keep it. However, if it's not the case and it's just for retrying accidental compilation failure or just to avoid `MJIT_ATOMIC_SET` and `compact_all_jit_code`, I think this quick stop path is not mandatory. Because this path is somewhat problematic in my upcoming fix in mjit_worker, let me try to remove this first and see how CI goes.
* mjit_worker.c: Add `-lm` to the C compiler in MJIT on AndroidYusuke Endoh2019-10-101-0/+3
| | | | | | To avoid: cannot locate symbol "modf" referenced by .../_ruby_mjit_XXX.so"
* RubyVM::MJIT.pause(wait: true) should waitTakashi Kokubun2019-09-261-3/+6
| | | | | | | | | | | for all compilations and compaction. Prior to this commit, the last-compiled code has not been used because MJIT worker is stopped before setting the code, and compaction has also been skipped. But it was not intentional and `wait: true` pause should wait until those two things by its feature.
* Split CC_LINKER_ARGS from CC_DLDFLAGS_ARGSTakashi Kokubun2019-08-301-5/+6
| | | | | | | | to drop MJIT_DLDFLAGS from compile_c_to_o for OpenBSD failure https://rubyci.org/logs/rubyci.s3.amazonaws.com/openbsd65/ruby-master/log/20190830T110008Z.fail.html.gz. 8c7f4e8f8b7f9e74195ea0eb51f39014fec342c0 did not work for i686-linux https://travis-ci.org/ruby/ruby/jobs/578808112.
* Try dropping DLDFLAGS from compile_c_to_oTakashi Kokubun2019-08-301-1/+1
| | | | | | | | I think this did not work for some environments, but this seems to fix OpenBSD RubyCI failure: https://rubyci.org/logs/rubyci.s3.amazonaws.com/openbsd65/ruby-master/log/20190830T110008Z.fail.html.gz Let me check RubyCI impact by this.
* Stop passing CC_LIBS in compile_c_to_oTakashi Kokubun2019-08-281-1/+1
| | | | | | | | | | | | | | To fix "gcc: -lgcc: linker input file unused because linking not done" in https://rubyci.org/logs/rubyci.s3.amazonaws.com/openbsd65/ruby-master/log/20190826T200009Z.log.html.gz Still I'm intentionally leaving CC_DLDFLAGS_ARGS because making compiler options different might result in compile/link failure. (Of course CC_DLDFLAGS_ARGS usually should not have compiler options, but it might include by bad configure setup) The same problem may exist in MJIT_LIBS used inside CC_LIBS as well, but I just ignored that case because it impacts only MinGW / cygwin, hoping that their users do not perform a wrong configure.
* Handle failure of opening a null deviceTakashi Kokubun2019-07-151-3/+7
| | | | This issue is detected by Coverity Scan.
* Simplify start_process by exploiting C99Takashi Kokubun2019-07-151-22/+18
| | | | | Having a block for mixing a declaration was confusing. Also I moved `dev_null` and `pid` to limit their scope.
* Always call va_end in form_args()Takashi Kokubun2019-07-151-1/+2
| | | | This issue is detected by Coverity Scan.
* Simplify link_o_to_so argumentsTakashi Kokubun2019-07-141-3/+1
| | | | by C99 compound literal for array and non-constant array initializer
* Fix a wrong buffer size to avoid stack corruptionTakashi Kokubun2019-07-141-2/+2
| | | | [Bug #15986]
* Refactor mjit_worker command line with C99Takashi Kokubun2019-07-141-35/+17
| | | | Mostly non-constatnt array initializer, and mixed declarations and code.
* Do not use rb_iseq_path() while moving ISeq pointersTakashi Kokubun2019-05-301-26/+14
| | | | | | | | in GC.compact. While `in_jit` is false, GC.compact is allowed to run and it may be moving ISeq-related pointers. So calling rb_iseq_path() when `in_jit` is true is illegal.
* Never make a method call from MJIT workerTakashi Kokubun2019-05-291-6/+9
| | | | | | by showing line number only when it's Fixnum. When it's not Fixnum, we need to call a method to know the line number.
* Do not call FIX2INT while GC.compact may be runningTakashi Kokubun2019-05-291-6/+6
| | | | | because FIX2INT might crash by moving method entry pointer: http://ci.rvm.jp/results/trunk-mjit@silicon-docker/2063412
* Rename mjit_gc_finish_hook to mjit_gc_exit_hookTakashi Kokubun2019-05-151-1/+1
| | | | | because @ko1 said "gc_finish" is confusing like a finish of entire GC process
* fix strict compile errorstenderlove2019-04-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e