aboutsummaryrefslogtreecommitdiffstats
path: root/ruby.c
Commit message (Collapse)AuthorAgeFilesLines
* Added `-W:experimental` to `--help` [Feature #16420]Nobuyoshi Nakada2019-12-241-0/+1
|
* Re-apply f85e8d2a8b keeping characters < 80Takashi Kokubun2019-12-221-1/+1
|
* Revert "Fixed misspellings"Yusuke Endoh2019-12-231-1/+1
| | | | | | This reverts commit f85e8d2a8b2a37740334db4fd92ef820f05ddbc5. It violated the limit of width (> 80) and caused the test failure
* Fixed misspellingsNobuyoshi Nakada2019-12-231-1/+1
| | | | Fixed misspellings reported at [Bug #16437]
* Added `-W:experimental` command line optionNobuyoshi Nakada2019-12-201-0/+3
| | | | [Feature #16420]
* Added -W: command line optionNobuyoshi Nakada2019-12-201-1/+29
| | | | | To manage `Warning[category]` flags. Only `-W:deprecated` and `-W:no-deprecated` are available now. [Feature #16345]
* Added `FEATURE_SET_RESTORE` macroNobuyoshi Nakada2019-12-201-1/+2
|
* use compiled binary for gem_prelude.rb.Koichi Sasada2019-12-111-1/+3
| | | | | `gem_prelude.rb` is not compiled yet. This patch compile it to compiled binary.
* Allow specifying arbitrary MJIT flags by --jit-debugTakashi Kokubun2019-12-011-1/+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.
* delete unused codes卜部昌平2019-11-181-4/+1
| | | | Suppress compiler warnings.
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-1/+0
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
* Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans2019-11-181-37/+19
| | | | | | | | | | | | | | | | | This removes the security features added by $SAFE = 1, and warns for access or modification of $SAFE from Ruby-level, as well as warning when calling all public C functions related to $SAFE. This modifies some internal functions that took a safe level argument to no longer take the argument. rb_require_safe now warns, rb_require_string has been added as a version that takes a VALUE and does not warn. One public C function that still takes a safe level argument and that this doesn't warn for is rb_eval_cmd. We may want to consider adding an alternative method that does not take a safe level argument, and warn for rb_eval_cmd.
* Refactor parser_params by removing "in_main" flagYusuke Endoh2019-10-041-10/+6
| | | | | | | | | | | | | | | | | | | The relation between parser_param#base_block and #in_main were very subtle. A main script (that is passed via a command line) was parsed under base_block = TOPLEVEL_BINDING and in_main = 1. A script loaded by Kernel#require was parsed under base_block = NULL and in_main = 0. If base_block is non-NULL and in_main == 0, it is parsed by Kernel#eval or family. However, we know that TOPLEVEL_BINDING has no local variables when a main script is parsed. So, we don't have to parse a main script under base_block = TOPLEVEL_BINDING. Instead, this change parses a main script under base_block = 0. If base_block is non-NULL, it is parsed by Kernel#eval or family. By this simplication, "in_main" is no longer needed.
* drop-in type check for rb_define_global_function卜部昌平2019-08-291-4/+4
| | | | | | We can check the function pointer passed to rb_define_global_function like we do so in rb_define_method. It turns out that almost anybody is misunderstanding the API.
* rb_define_hooked_variable now free from ANYARGS卜部昌平2019-08-271-7/+5
| | | | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit uses rb_gvar_getter_t / rb_gvar_setter_t for rb_define_hooked_variable / rb_define_virtual_variable which revealed lots of function prototype inconsistencies. Some of them were literally decades old, going back to dda5dc00cff334cac373096d444a0fd59e716124.
* ruby.c (name_match_p): remove unnecessary conditionYusuke Endoh2019-07-141-3/+2
| | | | | | It always returns immediately when len was decremented to zero. So len is always positive. This change will suppress Coverity Scan warning.
* * expand tabs.git2019-06-041-1/+1
|
* EOF by 2 ^D on a TTYNobuyoshi Nakada2019-06-041-1/+1
| | | | | | | Terminate the input from a TTY by 2 ^D at the middle of line, like as many programs, `cat`, `perl` and so on, do. By the first ^D, the line will be sent without a newline, and then EOF will be send by the next ^D.
* Do not modify shared arrayNobuyoshi Nakada2019-05-211-1/+12
| | | | [Bug #15821]
* ruby.c: respect features by command linenobu2019-03-301-18/+42
| | | | | | | | * ruby.c (process_options): feature options in command line arguments take precedence over options in RUBYOPT environment variable. [ruby-core:92052] [Bug #15738] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] fix markups [ci skip]nobu2019-03-281-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Change defaults of --jit optionsk0kubun2019-03-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * --jit-min-calls: 5 -> 10000 --jit-min-calls=5 obviously can compile non hotspot. This was not a problem for MJIT-benchmarks and Optcarrot because the former has very few hot optimiziable methods and the latter is likely to trigger compilation of hotspot by its intensive calls to optimizable hotspot methods and has a very short window to allow limited compilations. In real-world applications, it has more time to compile more methods and it pressures computer's limited resources like icache. We should avoid compiling too many methods. Also compiling many methods exhausts time budget for compilation in one ruby process lifetime and delays the "JIT compaction" of Ruby 2.6. JVM is known to use 1,500 for C1 (client) compiler and 10,000 for C2 (server) compiler for -XX:CompileThreshold by default. https://docs.oracle.com/javase/8/embedded/develop-apps-platforms/codecache.htm When things are called X,000 times, requiring 10,000 can eliminate compilation of methods which are called only once in these X,000 iterations and obviously not hotspot. And in fact things like unicorn-worker-killer restarts unicorn process every 4096 requests. So I felt 10,000 is good for such an environment. * --jit-max-cache: 1000 -> 100 By the same reason stated above, we should not allow compiling many methods especially on MJIT which has a larger overhead due to poor code locality by dlopen and whose code is also likely to be bigger by just inlining many VM instructions with -O3 rather than directly generating low-level code. In JVM -XX:ReservedCodeCacheSize is 32M for reserved and 48M for maximum. --jit-max-cache=1,000 could be closer to it, but in this case MJIT's compilation is slow due to data synchronization between threads (to be improved in Ruby 2.7 though) and we do not want to delay the "JIT compaction" for a long time. So I chose a really conservative number for this, but by having method inlining in the future, wider range could be optimized even with this value. * Optcarrot --disable-gems, --benchmark Lan_Master.nes 12 attempts. No significant impact. | r67276 | r67276 --jit | after --jit | |:-------------------|:------------------|:------------------| | 50.44369263063978 | 72.87390680773056 | 73.47873485047297 | | 50.58788746124193 | 78.06820808947026 | 78.29723420171945 | | 50.77509250801378 | 80.29010348842613 | 78.94689404460769 | | 50.935361702064405 | 80.42796829926374 | 80.39539527351525 | | 51.27352672981195 | 81.98758158033202 | 81.6754198664817 | | 51.720715743242124 | 82.00118535811626 | 82.22960569251283 | | 51.89643169822524 | 82.2290091613556 | 82.5013636146388 | | 51.95895898113868 | 82.37318990939565 | 82.74002377794454 | | 52.10124886807968 | 82.48796686037502 | 83.23354941183932 | | 52.292280637519376 | 83.0265226541066 | 84.01552618012572 | | 52.51856237784144 | 83.8797360318052 | 84.8588319093393 | | 52.65076845986818 | 84.80037351256634 | 85.13577756273656 | * Railsbench `WARMUP=20000 BENCHMARK=1000 bin/bench` of https://github.com/k0kubun/railsbench. It gets closer to --disable=jit. | | r67276 | r67276 | after | | | | --jit | --jit | |:----------|:-------|:-------|:-------| | req/s | 891.3 | 742.2 | 841.5 | |:----------|:-------|:-------|:-------| | 50%ile ms | 1.00 | 1.21 | 1.08 | | 66%ile ms | 1.02 | 1.24 | 1.09 | | 75%ile ms | 1.03 | 1.28 | 1.10 | | 80%ile ms | 1.03 | 1.30 | 1.11 | | 90%ile ms | 1.09 | 1.42 | 1.15 | | 95%ile ms | 1.32 | 1.65 | 1.27 | | 98%ile ms | 4.79 | 2.23 | 1.81 | | 99%ile ms | 5.68 | 7.52 | 6.64 | |100%ile ms | 6.52 | 9.69 | 8.59 | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Defer escaping control char in error messagesnobu2019-01-081-8/+1
| | | | | | | | * eval_error.c (print_errinfo): defer escaping control char in error messages until writing to stderr, instead of quoting at building the message. [ruby-core:90853] [Bug #15497] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix missed script_compiled events. [Bug #15471]ko12018-12-271-0/+12
| | | | | | | | | | | | | | * ruby.c (process_options): script_compiled events are missed on command line -e or specified file. this commit fix it. [Bug #15471] This patch should be backport to Ruby 2.6 branch. * vm_core.h (rb_exec_event_hook_script_compiled): introduce utility function to invoke a script_compiled event. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: do not surface MJIT to userk0kubun2018-11-191-8/+8
| | | | | | | | | | | In some places, both JIT and MJIT are being used, but it could be confusing for new comers. We're not explaining MJIT on NEWS file or release notes as well. So we consider MJIT as an internal term of implementation like YARV. configure.ac: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* AST.of -e scriptnobu2018-11-101-0/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix a warning message.ko12018-10-211-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add disabling MJIT features option.ko12018-10-201-0/+14
| | | | | | | | | | | | | | | | | | | | * 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
* Just a shebang is valid codenobu2018-10-021-5/+1
| | | | | | [ruby-core:89240] [Bug #15190] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* version.c: separate Init_ruby_descriptionnobu2018-08-101-0/+3
| | | | | | | * version.c (Init_ruby_description): separate to initialize RUBY_DESCRIPTION constant according to mjit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: taint ARGV on Windowsnobu2018-07-271-1/+3
| | | | | | | * ruby.c (external_str_new_cstr): strings come from the external should be tainted. [ruby-dev:50596] [Bug #14941] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dladdr() is declared with non-const pointer on Solarisnobu2018-07-261-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: accept --disable-jit optionk0kubun2018-07-181-3/+10
| | | | | | | | | | | | | | by promoting jit to feature flag. mjit.h: update comment about mjit_opts.on test_rubyoptions.rb: add test for switching JIT enablement "--jit" flag usage may be deprecated later, but not discussed yet. [Feature #14878] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: disable DidYouMean as gemnobu2018-07-161-3/+3
| | | | | | | * ruby.c (process_options): as DidYouMean requires Rubygems, disable the former when the latter is disabled too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* set up mjit.on at initializationnobu2018-07-021-4/+3
| | | | | | | * ruby.c (cmdline_options_init): set up mjit.on flag by MJIT_FORCE_ENABLE in the initialization function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: making hidden objectsnobu2018-06-111-4/+2
| | | | | | | * ruby.c (add_modules): make hidden objects by particular functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: localize a variablenobu2018-05-211-9/+9
| | | | | | | * ruby.c (ruby_init_loadpath_safe): moved libdir to the block where it is used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: runtime_libruby_pathnobu2018-05-211-49/+51
| | | | | | | | | * ruby.c (runtime_libruby_path): hoisted out platform dependent routine to get the loaded runtime library path. cygwin_conv_path does path separator and WCHAR to UTF-8 conversions too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RSTRING_PTR is not guaranteed to be char*-alignedshyouhei2018-05-101-1/+4
| | | | | | | | We need to ensure aligned memory access by allocating another memory region. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: moved libdirnobu2018-04-271-4/+4
| | | | | | | * ruby.c (ruby_init_loadpath_safe): moved libdir name inside LOAD_RELATIVE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: fix compilation errornobu2018-04-271-8/+9
| | | | | | | * ruby.c (ruby_init_loadpath_safe): fix compilation error when ENABLE_MULTIARCH but not universal binary. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c: prefix and archdir in initnobu2018-04-271-9/+32
| | | | | | | | | | * ruby.c (ruby_init_loadpath_safe): store prefix and archlibdir paths. * mjit.c (compile_c_to_so, init_header_filename): use just one library path on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c (ruby_init_loadpath_safe): constifynobu2018-04-261-5/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: exit by --versionnobu2018-03-271-1/+1
| | | | | | | * ruby.c (usage): stated exiting by `--version` option with nothing done. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: fix --verbose description in usagenobu2018-03-261-1/+2
| | | | | | | | * ruby.c (usage): fix the description of `--verbose` option, which does not print the version number unlike `-v` option. [ruby-core:86307] [Bug #14633] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: fix typo in r62530k0kubun2018-02-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* version.c: show +JIT when --jit is passedk0kubun2018-02-221-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in version output. version.h: ditto ruby.c: propagate option for it common.mk: updated dependency for version.c mjit.c: overwrites the RUBY_DESCRIPTION to have +JIT when --jit is passed test/ruby/test_rubyoptions.rb: add test for them Only `ruby --jit -v` will have "+JIT", but this is intentional. This may not be convenient for debugging by ticket with `ruby -v`, but it's convenient for benchmark tools that pass options (--jit) when showing it. At least such behavior is planned for benchmark_driver.gem and this behavior is designed for it. Other benchmark tools are recommended to follow the behavior too if they show version. RUBY_DESCRIPTION might be useful for it too. The position of "+JIT" is changed from original proposal because other platforms like JRuby and TruffleRuby end it with archtecture. It's made similar to JRuby, but it's upper-cased because Matz made approval for "+JIT" in the ticket. Example: $ ruby -v ruby 2.6.0dev (2018-02-22 trunk 62529) [x86_64-linux] $ ruby --jit -v ruby 2.6.0dev (2018-02-22 trunk 62529) +JIT [x86_64-linux] After --jit is made default in the future, this output may be removed. So do not rely on this output if possible. [Feature #14462] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* no --jit-ccnobu2018-02-121-18/+0
| | | | | | | | * ruby.c (setup_mjit_options): removed --jit-cc option, since mjit header is affected by generated config.h which depends on the given compiler, so it cannot work with different compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove declaration of ruby_engine from internal.husa2018-02-071-0/+1
| | | | | | | | | | * internal.h (ruby_engine): remove declaration of ruby_engine because it's declared at ruby/version.h. * ruby.c: include ruby/version.h for ruby_engine. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: add MJIT_FORCE_ENABLE macrok0kubun2018-02-061-0/+2
| | | | | | to always enable MJIT for testing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e