Commit graph

64552 commits

Author SHA1 Message Date
wanabe
6bc0c6c18b Adjust sp for case ... in pat1 | pat2 ... end 2020-08-16 18:39:08 +09:00
wanabe
0759862458 Adjust sp for pattern matching implicit/explicit "else" 2020-08-16 18:39:08 +09:00
git
c1e7f0c709 * 2020-08-16 [ci skip] 2020-08-16 08:43:57 +09:00
wanabe
a7bd0ec570 Warn sp overwriting on compile time 2020-08-16 08:43:29 +09:00
wanabe
ac399c2c7a Show hidden object and TS_BUILTIN for halfbaked insn data 2020-08-16 08:43:29 +09:00
Nobuyoshi Nakada
d75433ae19
[DOC] fixed a missing markup 2020-08-15 14:17:02 +09:00
卜部昌平
4d7818a299 tool/update-deps --fix 2020-08-15 12:09:26 +09:00
卜部昌平
ff30358d13 RARRAY_AREF: convert into an inline function
RARRAY_AREF has been a macro for reasons.  We might not be able to
change that for public APIs, but why not relax the situation internally
to make it an inline function.
2020-08-15 12:09:26 +09:00
git
72d0f2f0e0 * 2020-08-15 [ci skip] 2020-08-15 08:55:26 +09:00
Burdette Lamar
c84ccf1a07
Fix links to Dig Methods document (#3421)
* Fix links to Dig Methods document

* Fix links to Dig Methods document
2020-08-14 18:55:04 -05:00
Nobuyoshi Nakada
fee1b98fde
[DOC] fixed the method name 2020-08-14 16:33:47 +09:00
Nobuyoshi Nakada
e658040266
RSTRING_LEN was not used 2020-08-14 16:12:58 +09:00
Yusuke Endoh
4318aba9c9 re.c: prevent "warning: variable 'n' set but not used"
by adding MAYBE_UNUSED.
2020-08-14 08:51:14 +09:00
Burdette Lamar
22fd617aa5
Adding doc/dig_methods.rdoc and links to it (#3416)
Adds a full discussion of #dig, along with links from Array, Hash, Struct, and OpenStruct.

CSV::Table and CSV::Row are over in ruby/csv. I'll get to them soon.

The art to the thing is to figure out how much (or how little) to say at each #dig.
2020-08-13 13:16:27 -05:00
git
cead77d809 * 2020-08-14 [ci skip] 2020-08-14 02:16:15 +09:00
AGSaidi
511b55bcef
Enable arm64 optimizations that exist for power/x86 (#3393)
* Enable unaligned accesses on arm64

64-bit Arm platforms support unaligned accesses.

Running the string benchmarks this change improves performance
by an average of 1.04x, min .96x, max 1.21x, median 1.01x

* arm64 enable gc optimizations

Similar to x86 and powerpc optimizations.

|       |compare-ruby|built-ruby|
|:------|-----------:|---------:|
|hash1  |       0.225|     0.237|
|       |           -|     1.05x|
|hash2  |       0.110|     0.110|
|       |       1.00x|         -|

* vm_exec.c: improve performance for arm64

|                               |compare-ruby|built-ruby|
|:------------------------------|-----------:|---------:|
|vm_array                       |     26.501M|   27.959M|
|                               |           -|     1.06x|
|vm_attr_ivar                   |     21.606M|   31.429M|
|                               |           -|     1.45x|
|vm_attr_ivar_set               |     21.178M|   26.113M|
|                               |           -|     1.23x|
|vm_backtrace                   |       6.621|     6.668|
|                               |           -|     1.01x|
|vm_bigarray                    |     26.205M|   29.958M|
|                               |           -|     1.14x|
|vm_bighash                     |    504.155k|  479.306k|
|                               |       1.05x|         -|
|vm_block                       |     16.692M|   21.315M|
|                               |           -|     1.28x|
|block_handler_type_iseq        |       5.083|     7.004|
|                               |           -|     1.38x|
2020-08-14 02:15:54 +09:00
Nobuyoshi Nakada
787cb0fd86
Replace repeated RSTRING_PTR and RSTRING_LEN with RSTRING_GETMEM
As now RSTRING_PTR and RSTRING_LEN are functions, they very bother
stepping in/out during debugging.
2020-08-13 20:56:23 +09:00
Kasumi Hanazuki
014a4fda54 rb_str_{index,rindex}_m: Handle /\K/ in pattern
When the pattern Regexp given to String#index and String#rindex
contain a /\K/ (lookbehind) operator, these methods return the
position where the beginning of the lookbehind pattern matches, while
they are expected to return the position where the \K matches.

```
# without patch
"abcdbce".index(/b\Kc/)  # => 1
"abcdbce".rindex(/b\Kc/)  # => 4
```

This patch fixes this problem by using BEG(0) instead of the return
value of rb_reg_search.

```
# with patch
"abcdbce".index(/b\Kc/)  # => 2
"abcdbce".rindex(/b\Kc/)  # => 5
```

Fixes [Bug #17118]
2020-08-13 20:54:12 +09:00
Kasumi Hanazuki
5d71eed1a7 rb_str_{partition,rpartition}_m: Handle /\K/ in pattern
When the pattern given to String#partition and String#rpartition
contain a /\K/ (lookbehind) operator, the methods return strings
sliced at incorrect positions.

```
# without patch
"abcdbce".partition(/b\Kc/)  # => ["a", "c", "cdbce"]
"abcdbce".rpartition(/b\Kc/)  # => ["abcd", "c", "ce"]
```

This patch fixes the problem by using BEG(0) instead of the return
value of rb_reg_search.

```
# with patch
"abcdbce".partition(/b\Kc/)  # => ["ab", "c", "dbce"]
"abcdbce".rpartition(/b\Kc/)  # => ["abcdb", "c", "e"]
```

As a side-effect this patch makes String#partition 2x faster when the
pattern is a costly Regexp by performing Regexp search only once,
which was unexpectedly done twice in the original implementation.

Fixes [Bug #17119]
2020-08-13 20:50:50 +09:00
卜部昌平
69b5241c36 ruby_debug_log: suppress warning
Old gcc (< 5 maybe?) warns that this variable is not initialized:

    debug.c: In function 'ruby_debug_log':
    debug.c:441:13: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
                 ^

I don't know if that is true, but adding "= 0" here must harm no one.
2020-08-13 10:14:20 +09:00
卜部昌平
1f9e25cd02 MAYBE_UNUSED should just suffice
This reverts commit c355fa72d4.
2020-08-13 10:14:20 +09:00
Jeremy Evans
4fc6cfbeae Revert "Improve performance of partial backtraces"
This reverts commit f2d7461e85.

Some CI machines are reporting issues with backtrace_mark, so I'm
going to revert this for now.
2020-08-12 11:43:11 -07:00
git
6dfd7ad4f5 * 2020-08-13 [ci skip] 2020-08-13 03:03:49 +09:00
Jeremy Evans
f2d7461e85 Improve performance of partial backtraces
Previously, backtrace_each fully populated the rb_backtrace_t with all
backtrace frames, even if caller only requested a partial backtrace
(e.g. Kernel#caller_locations(1, 1)).  This changes backtrace_each to
only add the requested frames to the rb_backtrace_t.

To do this, backtrace_each needs to be passed the starting frame and
number of frames values passed to Kernel#caller or #caller_locations.

backtrace_each works from the top of the stack to the bottom, where the
bottom is the current frame.  Due to how the location for cfuncs is
tracked using the location of the previous iseq, we need to store an
extra frame for the previous iseq if we are limiting the backtrace and
final backtrace frame (the first one stored) would be a cfunc and not
an iseq.

To limit the amount of work in this case, while scanning until the start
of the requested backtrace, for each iseq, store the cfp.  If the first
backtrace frame we care about is a cfunc, use the stored cfp to find the
related iseq.  Use a function pointer to handle the storage of the cfp
in the iteration arg, and also store the location of the extra frame
in the iteration arg.

backtrace_each needs to return int instead of void in order to signal
when a starting frame larger than backtrace size is given, as caller
and caller_locations needs to return nil and not the empty array in
these cases.

To handle cases where a range is provided with a negative end, and the
backtrace size is needed to calculate the result to pass to
rb_range_beg_len, add a backtrace_size static function to calculate
the size, which copies the logic from backtrace_each.

As backtrace_each only adds the backtrace lines requested,
backtrace_to_*_ary can be simplified to always operate on the entire
backtrace.

Previously, caller_locations(1,1) was about 6.2 times slower for an
800 deep callstack compared to an empty callstack.  With this new
approach, it is only 1.3 times slower. It will always be somewhat
slower as it still needs to scan the cfps from the top of the stack
until it finds the first requested backtrace frame.

Fixes [Bug #17031]
2020-08-12 11:03:22 -07:00
Peter Zhu
166cacc505
Fix corruption in ARGF.inplace
Extension string stored in `ARGF.inplace` is created using an api
designed for C string constants to create a Ruby string that
points at another Ruby string. When the original string is swept,
the extension string gets corrupted.

Reproduction script (on MacOS):

```ruby
#!/usr/bin/ruby -pi.bak

BEGIN {
  GC.start(full_mark: true)
  arr = []
  1000000.times do |x|
    arr << "fooo#{x}"
  end
}

puts "hello"
```

Co-Authored-By: Matt Valentine-House <31869+eightbitraptor@users.noreply.github.com>
2020-08-12 17:54:09 +09:00
Kasumi Hanazuki
e79cdcf61b string.c(rb_str_split_m): Handle /\K/ correctly
Use BEG(0) instead of the result of rb_reg_search to handle the cases
when the separator Regexp contains /\K/ (lookbehind) operator.

Fixes [Bug #17113]
2020-08-12 10:01:39 +09:00
git
66efe37311 * 2020-08-12 [ci skip] 2020-08-12 01:02:18 +09:00
Alan Wu
7930a352a5 Test out fix for OpenSSL test flakiness
`OpenSSL::TestX509Store#test_verify` has been failing intermittently on
CI about once a day:
  - http://ci.rvm.jp/results/trunk-random2@phosphorus-docker/3121244
  - http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/3117661
  - http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/3111684

According to the test:
 > OpenSSL uses time(2) while Time.now uses clock_gettime(CLOCK_REALTIME),
 > and there may be difference.

This difference is could be the cause for the flaky failures. Let's see
if giving the certificate more room solves the problem.

In any case, I will revert this in a week. I think changes to these
should go to https://github.com/ruby/openssl/?
2020-08-11 12:01:51 -04:00
Takashi Kokubun
42725e3ab4
Enable s390x invokebuiltin JIT test again 2020-08-11 06:49:04 -07:00
Nobuyoshi Nakada
7806b2e28b
Use colorize.rb for non-capable terminals 2020-08-11 18:35:08 +09:00
Nobuyoshi Nakada
2e7fe3b687
Add default color for each instance 2020-08-11 18:35:07 +09:00
卜部昌平
5af983af4f template/prelude.c.tmpl: suppress clang-12 warning
Clang 12 warns "suspicious concatenation of string literals in an array
initialization", which is rather annoying than useful in this context.
2020-08-11 16:51:07 +09:00
卜部昌平
ef2b785b2d .github/workflows/compilers.yml: clang-12
LLVM made release/11.x branch.  Its master is now version 12.
2020-08-11 16:51:07 +09:00
卜部昌平
acd8ee8dbc tool/prelude.c.tmpl: use RubyVM::CEscape
Do not repeat yourself.
2020-08-11 16:51:07 +09:00
卜部昌平
b0eb5aa344 RubyVM::CEscape#rstring2cstr: do not escape '
A single quote "is representable either by itself or by the escape
sequence", according to ISO/IEC 9899 (checked all versions).  So this is
not a bug fix.  But the generated output is a bit readable without
backslashes.
2020-08-11 16:51:07 +09:00
Jeremy Evans
d43e99b722
Add Method Documentation Guide (#3399)
This documents how methods for core classes and classes in the
standard library should be documented.

Co-authored-by: Eric Hodel <drbrain@segment7.net>
2020-08-10 12:47:31 -07:00
git
404bff567d * 2020-08-11 [ci skip] 2020-08-11 01:33:54 +09:00
Burdette Lamar
c303e21d52
Enhanced RDoc for Array (#3400)
Methods:

    drop
    drop_while
    any?
    all?
    none?
    one?
2020-08-10 11:33:31 -05:00
Nobuyoshi Nakada
0ca6b973e8
Removed non-ASCII code to suppress warnings by localized compilers 2020-08-10 19:46:13 +09:00
Nobuyoshi Nakada
17d869c7d6
Check if C-sources are US-ASCII
Encoding of C-sources can not be determined, and non-ASCII code
are often warned by localized compilers.
2020-08-10 19:46:13 +09:00
Nobuyoshi Nakada
187c164d71
Suppress unused-variable warning
`key` is not used outside this assertion.
2020-08-10 17:49:08 +09:00
Nobuyoshi Nakada
c355fa72d4
Suppress unused-function warnings
Calls with a constant argument should be optimized away.
2020-08-10 17:47:34 +09:00
git
9260b0aece * 2020-08-10 [ci skip] 2020-08-10 16:36:35 +09:00
Nobuyoshi Nakada
fac62f094e
Adjust indent 2020-08-10 16:35:42 +09:00
git
b4b702dd4f * 2020-08-08 [ci skip] 2020-08-08 02:08:56 +09:00
Burdette Lamar
4126a979ae
Enhanced RDoc for Array#take and Array#take_while (#3398) 2020-08-07 12:08:36 -05:00
Burdette Lamar
615b7fa557
Enhanced RDoc for Array#product (#3395) 2020-08-07 06:52:37 -05:00
卜部昌平
504e632a15
sync NDEBUG, RUBY_DEBUG, and RUBY_NDEBUG (#3327)
- When NDEBUG is defined that shall be honoured.
- When RUBY_DEBUG is defined that shall be honoured.
- When both are defined and they conflict, warnings shall be rendered.
- When nothing is specified, nothing shall happen.
2020-08-07 14:01:13 +09:00
Hiroshi SHIBATA
8a99f820ce
Use zlib provided by vcpkg in mswin CI (#3397)
* Revert "mswin build - install src zlib files after checkout"

This reverts commit b6175c9e4f.

* Revert "mswin build - install src zlib files"

This reverts commit bf758ef8b4.
2020-08-07 12:28:39 +09:00
git
429efce4ed * 2020-08-07 [ci skip] 2020-08-07 00:17:15 +09:00