summaryrefslogtreecommitdiff
path: root/mjit_worker.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Avoid crash on logging GC-ed ISeqk0kubun2019-04-141-3/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Do not execute MJIT copy job when ISeq is GC-edk0kubun2019-04-141-2/+4
| | | | | | | | | I assumed that ISeq is never GC-ed by `in_jit` + `mjit_mark` on copy job ISeq, but unfortunately I found SEGV on `mjit_copy_job_handler` in which iseq->body was somehow Qnil. And it seems to be fixed by disabling the job when `mjit_free_iseq` is called for the ISeq. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add debug counter for MJIT stale_unitsk0kubun2019-04-141-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Unify comment styles across MJIT sourcesk0kubun2019-04-141-151/+146
| | | | | | | | | | | | 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
* Adjusted stylesnobu2019-04-101-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting all commits from r67479 to r67496 because of CI failureskazu2019-04-101-2/+1
| | | | | | | | Because hard to specify commits related to r67479 only. So please commit again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adjusted stylesnobu2019-04-101-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: explicitly ignore the unused result of RB_DEBUG_COUNTER_INC_IFmame2019-03-291-4/+4
| | | | | | By adding `(void)`. This makes Coverity Scan happy. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add mjit_compile_failures debug counterk0kubun2019-03-291-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prevent mjit length counters from being 0k0kubun2019-03-291-0/+10
| | | | | | | It seems that `debug_counter_show_results_at_exit` could be called earlier than `mjit_finish` sometimes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use alloca again instead of malloc and freek0kubun2019-03-181-29/+13
| | | | | | | | 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-46/+68
| | | | | | | | | 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 "Eliminate mjit_copy_job_t reference from mjit_worker"k0kubun2019-03-181-48/+37
| | | | | | | | This reverts commit ba51ae0109ee1d1fa7ca90b43da115ea68d7214a. CI is failing again... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Eliminate mjit_copy_job_t reference from mjit_workerk0kubun2019-03-181-37/+48
| | | | | | | | | | | | | | Take 2 of r67287. For some reasons, passing pointer of pointer on stack to a function and assigning an addresse to a pointer dereferenced from the pointer seems not working on mswin. So I achieved to return multiple values by returning struct instead of taking pointers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Request inline cache values from mjit_compile"k0kubun2019-03-181-61/+46
| | | | | | | | | | | | 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-20/+17
| | | | | | | | | | 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
* Eliminate mjit_copy_job_t reference from mjit_workerk0kubun2019-03-171-39/+57
| | | | | | | | | and make `copy_cache_from_main_thread` easier to use. For implementing inlining later, I'll use `copy_cache_from_main_thread` inside `mjit_compile`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Drop rb_mjit_unit from mjit_copy_jobk0kubun2019-03-171-7/+5
| | | | | | | | | and guard iseq from GC by marking iseq in mjit_copy_job. This is a refactoring for implementing inlining later and should not be fixing or introducing any bugs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix a typo [ci skip]kazu2019-03-171-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "mjit_worker.c: try to simplify CC_DLDFLAGS_ARGS"k0kubun2019-01-191-5/+11
| | | | | | | | | This reverts commit 405940234eb7876a063eb7129ca61fcc318a633c. Not working on MinGW https://ci.appveyor.com/project/ruby/ruby/builds/21737578/job/09a2tr94vof6fstt git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: try to simplify CC_DLDFLAGS_ARGSk0kubun2019-01-191-11/+5
| | | | | | assuming that -nostartfiles is just optional for mingw, cygwin, and AIX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: do not use GCC_NOSTDLIB_FLAGS for OpenBSDk0kubun2019-01-191-3/+3
| | | | | | | | | | | OpenBSD's GCC compiler has local extensions that break when `-nostartfiles -nodefaultlibs -nostdlib` is used. From: Jeremy Evans <merch-redmine@jeremyevans.net> [Bug #15548] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "mjit_worker.c: try passing -nostdlib to AIX"k0kubun2019-01-151-2/+2
| | | | | | | | This reverts commit b32fb23083912c37a2601c66531ed786a7c9f3e5. This didn't work on AIX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: pass -nostdlib when making pch as wellk0kubun2019-01-141-4/+12
| | | | | | [Bug #15513] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: try passing -nostdlib to AIXk0kubun2019-01-141-1/+1
| | | | | | r66812 might have allowed this. Testing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: pass -lgcc to GCC platformsk0kubun2019-01-141-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | using `-nodefaultlibs -nostdlib`. I assume libgcc is needed when we use -nostdlib, and it's linked on some platforms but not linked on some platforms (like aarch64, and possibly AIX as well) as said in https://wiki.osdev.org/Libgcc : > You can link with libgcc by passing -lgcc when linking your kernel with your compiler. You don't need to do this unless you pass the -nodefaultlibs option (implied by -nostdlib) Also note that -nostdlib is not strictly needed (rather implied -nodefaultlibs is problematic for Gentoo like Bug#15513, which will be approached later) but helpful for performance. So I want to keep it for now. [Bug #15522] I'm not trying to add `-nodefaultlibs -nostdlib` for AIX in this commit because AIX RubyCI is dead right now, but I'll try to add them again once RubyCI is fixed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: untangle CC_LIBS nestingk0kubun2019-01-141-5/+5
| | | | | | | | | | This should have no impact. The CC_LIBS was too hard to read for human. I don't remember whether the order of -lmsvcrt and -lgcc matters or not, but I kept that for the best safety. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* trivial fix r66778 [ci skip]kazu2019-01-121-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: use boolean type for boolean variablesk0kubun2019-01-101-52/+49
| | | | | | | | | | 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-39/+42
| | | | | | | | 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-42/+39
| | | | | | | | 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
* Fix styles [ci skip]nobu2019-01-091-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Enable MJIT on AIXodaira2018-12-041-1/+1
| | | | | | | | | | | | | | * configure.ac: disable using __builtin_setjmp to avoid errors when execution globally jumps out of JITted code. Specify -std=gnu99 to JIT compilation to avoid errors regarding the "restrict" keyword in the precompiled header. Specify -shared in addition to -Wl,-G when building shared libraries to make mjit_build_dir.so expose the MJIT_BUILD_DIR symbol. Use LDR_PRELOAD to load mjit_build_dir.so. * mjit_worker.c: do not specify -nodefaultlibs or -nostdlibs because on AIX JITted code internally refers to the memcpy function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: eliminate -save-temps flagk0kubun2018-12-031-5/+8
| | | | | | | | | | | | | | in a new variable cc_common_args. `cflags=-save-temps=obj` makes MJIT fail like: https://rubyci.org/logs/www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20181203T095000Z.log.html.gz This rubyci specifies -save-temps=obj in CFLAGS to use update-deps, and the flag is harmful when we want to use -pipe flag. mjit_worker.c: prefer cc_common_args over CC_COMMON_ARGS git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_worker.c: undefine CC_PATHk0kubun2018-12-031-4/+0
| | | | | | | | | because we mostly use cc_path now and the comment is obsolete (CC_PATH is now absolute path and the TODO is already resolved). mjit.c: use CC_COMMON_ARGS[0] directly git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e