Граф коммитов

628 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada b9d00f42e6
Enable escape sequence on Windows10 console via pager too 2020-12-21 18:12:02 +09:00
Jeremy Evans 05313c914b Use category: :deprecated in warnings that are related to deprecation
Also document that both :deprecated and :experimental are supported
:category option values.

The locations where warnings were marked as deprecation warnings
was previously reviewed by shyouhei.

Comment a couple locations where deprecation warnings should probably
be used but are not currently used because deprecation warning
enablement has not occurred at the time they are called
(RUBY_FREE_MIN, RUBY_HEAP_MIN_SLOTS, -K).

Add assert_deprecated_warn to test assertions.  Use this to simplify
some tests, and fix failing tests after marking some warnings with
deprecated category.
2020-12-18 09:54:11 -08:00
Nobuyoshi Nakada 8b32191a31 Ignore failure on unsupported fcntl to drop non-blocking mode 2020-12-16 17:54:43 +09:00
Jeremy Evans dca13e2bf7 Make ruby -We the same as ruby -W -e
This changes the behavior, which I'm not sure is acceptable.
However, it's odd to allow an option to be combined, but change
the behavior of the option when combined.
2020-12-10 10:16:40 -08:00
Kenta Murata 146b3695c0
ruby.c: remove needless substitution of uenc
uenc has already been initialized the top of the function.
2020-12-08 02:10:03 +09:00
Lars Kanis 94b6933d1c
Set default for Encoding.default_external to UTF-8 on Windows (#2877)
* Use UTF-8 as default for Encoding.default_external on Windows
* Document UTF-8 change on Windows to Encoding.default_external

fix https://bugs.ruby-lang.org/issues/16604
2020-12-08 01:48:37 +09:00
Nobuyoshi Nakada afd765f2ee
Initialize UTF-8 encoding first as it is used always now 2020-11-23 09:45:17 +09:00
Koichi Sasada 99310e3eb5 Some global variables can be accessed from ractors
Some global variables should be used from non-main Ractors.
[Bug #17268]

```ruby
     # ractor-local (derived from created ractor): debug
     '$DEBUG' => $DEBUG,
     '$-d' => $-d,

     # ractor-local (derived from created ractor): verbose
     '$VERBOSE' => $VERBOSE,
     '$-w' => $-w,
     '$-W' => $-W,
     '$-v' => $-v,

     # process-local (readonly): other commandline parameters
     '$-p' => $-p,
     '$-l' => $-l,
     '$-a' => $-a,

     # process-local (readonly): getpid
     '$$'  => $$,

     # thread local: process result
     '$?'  => $?,

     # scope local: match
     '$~'  => $~.inspect,
     '$&'  => $&,
     '$`'  => $`,
     '$\''  => $',
     '$+'  => $+,
     '$1'  => $1,

     # scope local: last line
     '$_' => $_,

     # scope local: last backtrace
     '$@' => $@,
     '$!' => $!,

     # ractor local: stdin, out, err
     '$stdin'  => $stdin.inspect,
     '$stdout' => $stdout.inspect,
     '$stderr' => $stderr.inspect,
```
2020-10-20 15:38:54 +09:00
Nobuyoshi Nakada 996af2ce08 Disable deprecation warning by the default [Feature #16345]
And `-w` option turns it on.
2020-09-25 09:50:33 +09:00
Nobuyoshi Nakada 0dbf6e46fb
[Feature #17157] removed -T command line option 2020-09-07 00:59:53 +09:00
卜部昌平 7cf4625690 feature_option: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
Nobuyoshi Nakada 9ce2066209
Improved error messages for mjit option
and default jit-verbose to 1 if no argument.
2020-06-23 10:01:24 +09:00
Nobuyoshi Nakada 2c3c6c96cf
Defer initialization
Defer initialization of extension libraries, loading prelude files
and requiring files, and skip if dump options are given.
2020-05-16 17:37:28 +09:00
Yusuke Endoh 39365b46e2
Merge pull request #3047 from mame/suppress-backtrace
Add `--suppress-backtrace=num` option to limit the backtrace length
2020-05-15 01:22:56 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
Yusuke Endoh 91e4e2403e internal/process.h: add a no-warning simple wrapper for fork(2)
As fork(2) is deprecated, its calls must be guarded by
`COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)`.
All usages of fork(2) in process have been alread guarded.  A new call
to fork(2) was added in ruby.c with f22c4ff359.
This caused a build failure on Solaris 11.

It may hide a bug to guard big code unnecessarily, so this change
introduces a simple wrapper "rb_fork" whose definition is guarded, and
replaces all calls to fork(2) with the wrapper function.
2020-05-02 21:34:10 +09:00
Nobuyoshi Nakada a07cbacd23 Honor COLUMNS [Feature #16754] 2020-04-12 14:58:13 +09:00
Nobuyoshi Nakada cc68d2fbd0 Hightlight usage [Feature #16754] 2020-04-12 14:58:13 +09:00
Nobuyoshi Nakada 3825662d77 Set up environment variable for pager [Feature #16754] 2020-04-12 14:58:13 +09:00
Nobuyoshi Nakada e6551d835f PAGER without fork&exec too [Feature #16754] 2020-04-12 14:58:13 +09:00
Nobuyoshi Nakada f22c4ff359 View the help message with PAGER [Feature #16754]
View the help message wth pager designed by RUBY_PAGER or PAGER
environment variable, unless that value is empty.
2020-04-12 14:58:13 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Yusuke Endoh c6b26f5ccf io.c, ruby.c: include internal/variable.h for rb_gvar_readonly_setter
Same as 053f78e139.
emscripten requires a prototype declaration of rb_gvar_readonly_setter
if it is refered as a function pointer.
2020-01-09 23:57:46 +09:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
Nobuyoshi Nakada 3739ddc36f
Added `-W:experimental` to `--help` [Feature #16420] 2019-12-24 12:11:42 +09:00
Takashi Kokubun 4de2297d74
Re-apply f85e8d2a8b keeping characters < 80 2019-12-22 16:07:12 -08:00
Yusuke Endoh f156f70b31 Revert "Fixed misspellings"
This reverts commit f85e8d2a8b.

It violated the limit of width (> 80) and caused the test failure
2019-12-23 09:02:49 +09:00
Nobuyoshi Nakada f85e8d2a8b
Fixed misspellings
Fixed misspellings reported at [Bug #16437]
2019-12-23 08:41:34 +09:00
Nobuyoshi Nakada 484c1be895
Added `-W:experimental` command line option
[Feature #16420]
2019-12-20 23:51:17 +09:00
Nobuyoshi Nakada a84ad24386
Added -W: command line option
To manage `Warning[category]` flags.  Only `-W:deprecated` and
`-W:no-deprecated` are available now.  [Feature #16345]
2019-12-20 23:05:22 +09:00
Nobuyoshi Nakada 6876aa38f6
Added `FEATURE_SET_RESTORE` macro 2019-12-20 22:58:09 +09:00
Koichi Sasada 2c5c60754c use compiled binary for gem_prelude.rb.
`gem_prelude.rb` is not compiled yet. This patch compile it to
compiled binary.
2019-12-11 11:24:42 +09:00
Takashi Kokubun a19d625e66
Allow specifying arbitrary MJIT flags by --jit-debug
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.
2019-12-01 00:58:47 -08:00
卜部昌平 7a9b2039b7 delete unused codes
Suppress compiler warnings.
2019-11-18 18:28:03 +09:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
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.
2019-11-18 01:00:25 +02:00
Jeremy Evans c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
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.
2019-11-18 01:00:25 +02:00
Yusuke Endoh 711c40ebdc Refactor parser_params by removing "in_main" flag
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.
2019-10-04 02:30:36 +09:00
卜部昌平 7bcfd9189a drop-in type check for rb_define_global_function
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.
2019-08-29 18:34:09 +09:00
卜部昌平 ae2dc3f217 rb_define_hooked_variable now free from ANYARGS
After 5e86b005c0, 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 dda5dc00cf.
2019-08-27 15:52:26 +09:00
Yusuke Endoh 085d0e5ccb ruby.c (name_match_p): remove unnecessary condition
It always returns immediately when len was decremented to zero.
So len is always positive.  This change will suppress Coverity Scan
warning.
2019-07-14 21:58:22 +09:00
git 14b5ccf91b * expand tabs. 2019-06-04 09:36:32 +09:00
Nobuyoshi Nakada aa8d393d8a
EOF by 2 ^D on a TTY
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.
2019-06-04 09:24:17 +09:00
Nobuyoshi Nakada ac00bdc8a8
Do not modify shared array
[Bug #15821]
2019-05-21 14:17:51 +09:00
nobu b84eed5dd8 ruby.c: respect features by command line
* 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
2019-03-30 14:31:35 +00:00
nobu de0ef1a9df [DOC] fix markups [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-28 03:33:35 +00:00
k0kubun 0fa4a6a618 Change defaults of --jit options
* --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
2019-03-17 05:13:38 +00:00
nobu 50784a0a44 Defer escaping control char in error messages
* 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
2019-01-08 09:08:31 +00:00
ko1 496267023c fix missed script_compiled events. [Bug #15471]
* 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
2018-12-27 17:39:17 +00:00
k0kubun b756b25c60 ruby.c: do not surface MJIT to user
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
2018-11-19 14:00:49 +00:00