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

72335 Коммитов

Автор SHA1 Сообщение Дата
Burdette Lamar c2468fd88b [ruby/fileutils] Enhanced RDoc (https://github.com/ruby/fileutils/pull/82)
Treats ::chmod; adds Pathname usage to ::install.

https://github.com/ruby/fileutils/commit/9db4cb129c
2022-06-10 05:03:33 +09:00
Alexander Ilyin adcfd69690
[DOC] Fix markup for `String` (#5984)
* Add missing space for `String#start_with?`.
* Add missing pluses for `String#tr` and
  `Methods for Converting to New String` label.
* Move quote into the tag for `Whitespace in Strings` label.
2022-06-09 13:40:21 -05:00
Eileen M. Uchitelle 473ee328c5
Add ability to trace exit locations in yjit (#5970)
When running with `--yjit-stats` turned on, yjit can inform the user
what the most common exits are. While this is useful information it
doesn't tell you the source location of the code that exited or what the
code that exited looks like. This change intends to fix that.

To use the feature, run yjit with the `--yjit-trace-exits` option,
which will record the backtrace for every exit that occurs. This functionality
requires the stats feature to be turned on. Calling `--yjit-trace-exits`
will automatically set the `--yjit-stats` option.

Users must call `RubyVM::YJIT.dump_exit_locations(filename)` which will
Marshal dump the contents of `RubyVM::YJIT.exit_locations` into a file
based on the passed filename.

*Example usage:*

Given the following script, we write to a file called
`concat_array.dump` the results of `RubyVM::YJIT.exit_locations`.

```ruby
def concat_array
  ["t", "r", *x = "u", "e"].join
end

1000.times do
  concat_array
end

RubyVM::YJIT.dump_exit_locations("concat_array.dump")
```

When we run the file with this branch and the appropriate flags the
stacktrace will be recorded. Note Stackprof needs to be installed or you
need to point to the library directly.

```
./ruby --yjit --yjit-call-threshold=1 --yjit-trace-exits -I/Users/eileencodes/open_source/stackprof/lib test.rb
```

We can then read the dump file with Stackprof:

```
./ruby -I/Users/eileencodes/open_source/stackprof/lib/ /Users/eileencodes/open_source/stackprof/bin/stackprof --text concat_array.dump
```

Results will look similar to the following:

```
==================================
  Mode: ()
  Samples: 1817 (0.00% miss rate)
  GC: 0 (0.00%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
      1001  (55.1%)        1001  (55.1%)     concatarray
       335  (18.4%)         335  (18.4%)     invokeblock
       178   (9.8%)         178   (9.8%)     send
       140   (7.7%)         140   (7.7%)     opt_getinlinecache
       ...etc...
```

Simply inspecting the `concatarray` method will give `SOURCE
UNAVAILABLE` because the source is insns.def.

```
./ruby -I/Users/eileencodes/open_source/stackprof/lib/ /Users/eileencodes/open_source/stackprof/bin/stackprof --text concat_array.dump --method concatarray
```

Result:

```
concatarray (nonexistent.def:1)
  samples:  1001 self (55.1%)  /   1001 total (55.1%)
  callers:
    1000  (   99.9%)  Object#concat_array
       1  (    0.1%)  Gem.suffixes
  callees (0 total):
  code:
        SOURCE UNAVAILABLE
```

However if we go deeper to the callee we can see the exact
source of the `concatarray` exit.

```
./ruby -I/Users/eileencodes/open_source/stackprof/lib/ /Users/eileencodes/open_source/stackprof/bin/stackprof --text concat_array.dump --method Object#concat_array
```

```
Object#concat_array (/Users/eileencodes/open_source/rust_ruby/test.rb:1)
  samples:     0 self (0.0%)  /   1000 total (55.0%)
  callers:
    1000  (  100.0%)  block in <main>
  callees (1000 total):
    1000  (  100.0%)  concatarray
  code:
                                  |     1  | def concat_array
 1000   (55.0%)                   |     2  |   ["t", "r", *x = "u", "e"].join
                                  |     3  | end
```

The `--walk` option is recommended for this feature as it make it
easier to traverse the tree of exits.

*Goals of this feature:*

This feature is meant to give more information when working on YJIT.
The idea is that if we know what code is exiting we can decide what
areas to prioritize when fixing exits. In some cases this means adding
prioritizing avoiding certain exits in yjit. In more complex cases it
might mean changing the Ruby code to be more performant when run with
yjit. Ultimately the more information we have about what code is exiting
AND why, the better we can make yjit.

*Known limitations:*

* Due to tracing exits, running this on large codebases like Rails
can be quite slow.
* On complex methods it can still be difficult to pinpoint the exact cause of
an exit.
* Stackprof is a requirement to to view the backtrace information from
the dump file.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2022-06-09 12:59:39 -04:00
git 1b5828f9a6 * 2022-06-10 [ci skip] 2022-06-10 00:22:27 +09:00
Jeremy Evans 27eb36596a Stop ignoring 4th positional argument to IO.#{foreach,readlines}
Fixes [Bug #18771]
2022-06-09 08:22:06 -07:00
xtkoba 940c8b093d Skip `NULL` values from `dladdr(3)`
Fixes [Bug #17810]
2022-06-09 20:43:41 +09:00
Jean Boussier 4e21b19a61 [ruby/timeout] Keep a private reference to `Process.clock_gettime`
`timeout 0.3.0` broke our test suite because we have some
tests that stubs `Process.clock_gettime` making it return
a value in the past, causing `Timeout` to trigger almost immediately.

I beleive it wasn't a problem before because it was relying on `Process.sleep`.

https://github.com/ruby/timeout/commit/e5911a303e
2022-06-09 18:58:49 +09:00
Yusuke Endoh bda4d91f05 doc/case_mapping.rdoc: Fix references for case mapping
The chart (https://www.unicode.org/charts/case) that is currently
referred seems to be wrong.

Also, use the "latest" redirect and add titles of the section and table.
[Bug #18590]
2022-06-09 18:21:39 +09:00
Takashi Kokubun 90b240d127
Fix MJIT's ISEQ_BODY macro usage at 5f10bd634f 2022-06-08 22:39:18 -07:00
Takashi Kokubun 2931957d6f
MJIT: Ignore existence of .bundle.dSYM on macOS
We could fix it, but removing files in the directory recursively is
tedious in C and --mjit-debug is not a concern for users. We have
TestMJITDebug for detecting linker problems that are ignored by -O. It's
not really for maintaining --mjit-debug itself.
2022-06-08 21:19:03 -07:00
Kazuhiro NISHIYAMA 67a9845a7a
Fix compile error
```
compiling ../debug.c
../debug.c:452:1: error: conflicting types for 'ruby_debug_log_filter'
ruby_debug_log_filter(const char *func_name, const char *file_name)
^
../vm_debug.h:87:6: note: previous declaration is here
bool ruby_debug_log_filter(const char *func_name);
     ^
1 error generated.
make: *** [debug.o] Error 1
```
2022-06-09 09:35:08 +09:00
Burdette Lamar 9b7208fca1 [ruby/fileutils] [DOC] Enhanced RDoc (https://github.com/ruby/fileutils/pull/81)
https://github.com/ruby/fileutils/commit/b9d5a79e38
2022-06-09 05:38:09 +09:00
Takashi Kokubun da883af42a
MJIT: Directly compile .c to .so (#5987)
I'm planning to redesign the MJIT worker pipeline, and this allows you to simplify the implementation and let it run efficiently except for MinGW.
2022-06-08 10:49:00 -07:00
Koichi Sasada 5a4f997b2e func: and file: prefix for `RUBY_DEBUG_LOG_FILTER`
`RUBY_DEBUG_LOG_FILTER` specified only function names but this
patch also check file names for each log events.
If you specify `file:` or `func:` prefix, it's only filter
file names or func names (otherwize check both).

  foo
  # show log when file or func names are mached with foo

  func:foo
  # show log when func name matches foo

  file:foo
  # show log when file name matches foo

  -file:foo,func:bar
  # show log when file name does not contains foo
  #           and func name matches bar
2022-06-09 01:51:19 +09:00
Peter Zhu 8d57336360 Fix major GC thrashing
Only growth heaps are allowed to start major GCs. Before this patch,
growth heaps are defined as size pools that freed more slots than had
empty slots (i.e. there were more dead objects that empty space).

But if the size pool is relatively stable and tightly packed with mostly
old objects and has allocatable pages, then it would be incorrectly
classified as a growth heap and trigger major GC. But since it's stable,
it would not use any of the allocatable pages and forever be classified
as a growth heap, causing major GC thrashing. This commit changes the
definition of growth heap to require that the size pool to have no
allocatable pages.
2022-06-08 12:09:19 -04:00
git 08a6ec341e * 2022-06-09 [ci skip] 2022-06-09 00:26:19 +09:00
Peter Zhu d1b6c8a1cc Fix compilation error when USE_RVARGC=0
force_major_gc_count was not defined when USE_RVARGC=0.
2022-06-08 11:25:31 -04:00
Peter Zhu fafe68185c Add key force_major_gc_count to GC.stat_heap
force_major_gc_count is the number of times the size pool forced major
GC to run.
2022-06-08 10:03:00 -04:00
Burdette Lamar a07acbe417 [ruby/fileutils] File trees (https://github.com/ruby/fileutils/pull/80)
Adds a note about file tree examples.

https://github.com/ruby/fileutils/commit/65ac65067a
2022-06-08 21:35:00 +09:00
Alexander Ilyin 6a6531d3e0 Update "Reporting Issues" link in the README
This link is broken.
2022-06-08 17:49:56 +09:00
Takashi Kokubun 790825db44
Update the help message on /benchmark
I wanted to point out there's --output=all.
2022-06-07 21:30:28 -07:00
Nobuyoshi Nakada ccfbcc7302
[DOC] RDoc now accepts other than magic numbers at `rb_attr` 2022-06-08 11:55:21 +09:00
Peter Zhu bf4684d999 Remove duplicated prototype in header file
rb_imemo_new is defined again later in the file.
2022-06-07 14:15:59 -04:00
Jean Boussier 19c6aaca93 thread_pthread.c: trigger THREAD_EVENT_READY when going throuhg the fast path. 2022-06-07 18:15:55 +02:00
git bdc6e991f5 * 2022-06-08 [ci skip] 2022-06-08 00:21:12 +09:00
Noah Gibbs 1598c9458a
Add special-case code for the String unary plus operator (#5982) 2022-06-07 11:20:57 -04:00
Daniel Berger deff9e2699 [rubygems/rubygems] Remove unnecessary string concatenation
https://github.com/rubygems/rubygems/commit/81ccb3ab89
2022-06-07 23:18:31 +09:00
Peter Zhu c4bf24ee46 Remove while loop over heap_prepare
Having a while loop over `heap_prepare` makes the GC logic difficult to
understand (it is difficult to understand when and why `heap_prepare`
yields a free page). It is also a source of bugs and can cause an infinite
loop if `heap_page` never yields a free page.
2022-06-07 09:56:20 -04:00
David Rodríguez f50432fba8 [rubygems/rubygems] Relax performance spec limit
https://github.com/rubygems/rubygems/commit/eab417d0ce
2022-06-07 21:04:53 +09:00
Jean Boussier b1e6e58cd1 Refactor TestThreadInstrumentation to investigate CI flakiness
`test_thread_instrumentation_fork_safe` has been failing occasionaly
on Ubuntu and Arch. At this stage we're not sure why, all we know is
that the child exit with status 1.

I suspect that something entirely unrelated cause the forked children
to fail on exit, so by using `exit!(0)` and doing assertions in the
parent I hope to be resilient to that.
2022-06-07 13:19:34 +02:00
Yusuke Endoh f075be3dcb [ruby/error_highlight] Use Exception#detailed_message instead of overriding #message (https://github.com/ruby/error_highlight/pull/24)
See https://bugs.ruby-lang.org/issues/18564.
Ref: https://github.com/ruby/did_you_mean/pull/177

https://github.com/ruby/error_highlight/commit/671b7c61b2
2022-06-07 17:40:19 +09:00
Hiroshi SHIBATA 11b9dd8ccb
Manually merged https://github.com/ruby/did_you_mean/pull/177 2022-06-07 15:24:48 +09:00
Yusuke Endoh b9f030954a Revert "error.c: Let Exception#inspect inspect its message"
This reverts commit 9d927204e7.
2022-06-07 11:52:44 +09:00
Nobuyoshi Nakada 082c2d1b05 [ruby/rdoc] [DOC] Undocument internal constants [ci skip]
https://github.com/ruby/rdoc/commit/6d7bf24bb8
2022-06-07 11:44:58 +09:00
Yusuke Endoh 9d927204e7 error.c: Let Exception#inspect inspect its message
... only when the message string has a newline.

`p StandardError.new("foo\nbar")` now prints `#<StandardError: "foo\nbar">'
instead of:

    #<StandardError:
    bar>

[Bug #18170]
2022-06-07 11:07:09 +09:00
Nobuyoshi Nakada dbfb3b1917 [ruby/rdoc] Allow boolean arguments to `rb_attr` and `rb_define_attr`
Currently only literal `0` and `1` are accepted as `read`/`write`
flags.
This patch allows other boolean arguments, C macros (`FALSE`/`TRUE`),
Ruby `VALUE`s (`Qfalse`/`Qtrue`), and C99 `bool`s (`false`/`true`), as
well.

https://github.com/ruby/rdoc/commit/169dc02e3c
2022-06-07 10:42:10 +09:00
Jun Aruga cfcf33f127 .github/workflows/compilers.yml: annocheck: Fix a linker flag to pass MJIT tests.
Set the linker flag `-Wl,-z,now` properly.

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>

Fixes [Bug #18781]
2022-06-07 00:25:19 +02:00
Jeremy Evans ec3542229b
Ignore invalid escapes in regexp comments
Invalid escapes are handled at multiple levels.  The first level
is in parse.y, so skip invalid unicode escape checks for regexps
in parse.y.

Make rb_reg_preprocess and unescape_nonascii accept the regexp
options.  In unescape_nonascii, if the regexp is an extended
regexp, when "#" is encountered, ignore all characters until the
end of line or end of regexp.

Unfortunately, in extended regexps, you can use "#" as a non-comment
character inside a character class, so also parse "[" and "]"
specially for extended regexps, and only skip comments if "#" is
not inside a character class. Handle nested character classes as well.

This issue doesn't just affect extended regexps, it also affects
"(#?" comments inside all regexps.  So for those comments, scan
until trailing ")" and ignore content inside.

I'm not sure if there are other corner cases not handled.  A
better fix would be to redesign the regexp parser so that it
unescaped during parsing instead of before parsing, so you already
know the current parsing state.

Fixes [Bug #18294]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-06-06 13:50:03 -07:00
Jeremy Evans c85d1cda86 Fix Module#const_source_location for autoload constants with direct requires
If an autoload exists for a constant, but the path for the autoload
was required, const_source_location would return [false, 0] instead
of the actual file and line. This fixes it by setting the appropriate
file and line in rb_const_set, and saving the file and line in
const_tbl_update before they get reset by current_autoload_data.

Fixes [Bug #18624]
2022-06-06 11:12:55 -07:00
Noah Gibbs 653e517eef
Use bindgen to import Ruby constants wherever possible. (#5943)
Constants that can't be imported via bindgen should have
a comment saying why not.
2022-06-06 13:47:24 -04:00
Jeremy Evans c5475f4269 Fix Range#cover? returning true for beginless ranges of different types
Previously `(2..).cover?("2"..)` was false, but
`(..2).cover?(.."2")` was true.  This changes it so both are false,
treating beginless ranges the same as endless ranges in regards to
type checks.

This also adds documentation to #cover? to describe behavior with
beginless and endless ranges, testing each documentation example,
which is how this bug was found.

Fixes [Bug #18155]
2022-06-06 09:59:22 -07:00
Jeremy Evans 7cda7fbbdc
Add Module#undefined_instance_methods
Implements [Feature #12655]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-06-06 09:57:32 -07:00
Burdette Lamar b737998d25 [ruby/fileutils] [DOC] Enhanced RDoc for FileUtils (https://github.com/ruby/fileutils/pull/78)
Treats:
    ::rm
    ::rm_f
    ::rm_r
    ::rm_rf
    ::remove_entry_secure

https://github.com/ruby/fileutils/commit/ce2a438d75
2022-06-07 00:37:31 +09:00
git f2f8c0b39b * 2022-06-07 [ci skip] 2022-06-07 00:07:09 +09:00
Alexander Ilyin 6fc16e748e [ruby/open-uri] [DOC] Fix markup for `URI.open`
* Add missing slash.

https://github.com/ruby/open-uri/commit/40023e63da
2022-06-07 00:06:56 +09:00
Nobuyoshi Nakada 66a9e452bb [ruby/rdoc] Use runnable command as DUMMY_PAGER
https://github.com/ruby/rdoc/commit/fec1ab2e41
2022-06-06 21:19:45 +09:00
David Rodríguez ba38318827 [rubygems/rubygems] Unify loading `Gem::Requirement`
It was being explicitly required from `Gem::Specification` but also a
strange autoload was set for it at `Gem::Version`. The autoload was non
standard because it should've been done in the `Gem` module, not in
`Gem::Specification`, since that's where the constant is expected to get
defined. Doing this might get deprecated in the future, and it was not
being effective anyways due to the explicit require.

Unify everything with an `autoload` at the right place.

https://github.com/rubygems/rubygems/commit/174ea3e24c
2022-06-06 18:36:31 +09:00
Hiroshi SHIBATA f4173ff2fa
debug is the bundled gems, not default gems 2022-06-06 18:19:15 +09:00
Pavel Rosický 4bc7cef866
[ruby/cgi] jruby support
https://github.com/ruby/cgi/commit/93326fb622
2022-06-06 18:13:01 +09:00
Yusuke Endoh 5d014bcb61 Use `sleep 0.5` for tests of GVL instrumentation API
The tests fail randomly on some platforms.

http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20220605T213004Z.fail.html.gz
http://rubyci.s3.amazonaws.com/arch/ruby-master/log/20220605T210003Z.fail.html.gz
```
[15737/21701] TestThreadInstrumentation#test_thread_instrumentation_fork_safe/home/chkbuild/chkbuild/tmp/build/20220605T213004Z/ruby/tool/lib/test/unit/assertions.rb:109:in `assert': Expected 0 to be nonzero?. (Test::Unit::AssertionFailedError)
```

The failures seem to depend on context switches. I suspect `sleep 0.05`
is too short, so this change tries to extend the wait time.
2022-06-06 12:52:15 +09:00