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

62277 Коммитов

Автор SHA1 Сообщение Дата
git c4bdb6428e * 2020-07-05 [ci skip] 2020-07-05 02:02:44 +09:00
Sam Bostock bf1a6771f3 Fix non-numeric exclusive Range#minmax bug
The implementation of Range#minmax added in d5c60214c4 causes the
following incorrect behaviour:

  ('a'...'c').minmax => ["a", ["a", "b"]]

instead of

  ('a'...'c').minmax => ["a", "b"]

This is because the C implementation of Range#minmax (range_minmax)
directly delegates to the C implementation of Range#min (range_min) and
Range#max (range_max), without changing the execution context.

Range#max's C implementation (range_max), when given a non-numeric
exclusive range, delegates to super, which is meant to call
Enumerable#max. However, because range_max is called directly by
range_minmax, super calls Enumerable#minmax instead, causing the
incorrect nesting.

Perhaps it is possible to change the execution context in an optimized
manner, but the simplest solution seems to be to just explicitly
delegate from Range#minmax to Range#min and Range#max.
2020-07-04 10:02:24 -07:00
Nobuyoshi Nakada 9fc564cfef
Ignore rbenv version file, and moved dot files [ci skip] 2020-07-04 22:04:46 +09:00
Koichi Sasada 74e1bca79d support all locals for cexpr!, cstmt!
Primitve.cexpr! and .cstmt! can access Ruby's parameter and
*local variables* (note that local parameters are also local
variables). However recent changes only allow to access
parameters. This patch fix it.

For example, the following code can work:

def foo a, b, k: :kw, **kwrest
  c = a + b
  d = k
  e = kwrest
  p Primitive.cstmt!(%q(rb_p(rb_ary_new_from_args(5, a, b, c, d, e));
                        return Qnil;))
end
2020-07-04 17:28:23 +09:00
David Rodríguez 7a5da7d55d Allow hidden files with a hyphen to be source controlled
Latest bundler includes a file named `.gitlab-ci.yml.tt`. Because of
this too specific .gitignore entry, it was failing to be properly
imported.
2020-07-04 13:41:17 +09:00
Takashi Kokubun 24fa37d87a
Make Kernel#then, #yield_self, #frozen? builtin (#3283)
* Make Kernel#then, #yield_self, #frozen? builtin

* Fix test_jit
2020-07-03 18:02:43 -07:00
Takashi Kokubun a69dd699ee
Merge ivar guards on JIT (#3284)
when an ISeq has multiple ivar accesses.
2020-07-03 17:52:52 -07:00
git ccb2e6eaa5 * 2020-07-04 [ci skip] 2020-07-04 01:52:54 +09:00
Takashi Kokubun f3a0d7a203
Rewrite Kernel#tap with Ruby (#3281)
* Rewrite Kernel#tap with Ruby

This was good for VM too, but of course my intention is to unblock JIT's inlining of a block over yield
(inlining invokeyield has not been committed though).

* Fix test_settracefunc

About the :tap deletions, the :tap events are actually traced (we already have a TracePoint test for builtin methods),
but it's filtered out by tp.path == "xyzzy" (it became "<internal:kernel>"). We could trace tp.path == "<internal:kernel>"
cases too, but the lineno is impacted by kernel.rb changes and I didn't want to make it fragile for kernel.rb lineno changes.
2020-07-03 09:52:35 -07:00
Burdette Lamar e8010c7401
Enhanced RDoc for Array (#3276)
*Methods:

    keep_if
    delete
    delete_at
    slice!
2020-07-03 09:49:36 -05:00
Koichi Sasada a0f12a0258
Use ID instead of GENTRY for gvars. (#3278)
Use ID instead of GENTRY for gvars.

Global variables are compiled into GENTRY (a pointer to struct
rb_global_entry). This patch replace this GENTRY to ID and
make the code simple.

We need to search GENTRY from ID every time (st_lookup), so
additional overhead will be introduced.
However, the performance of accessing global variables is not
important now a day and this simplicity helps Ractor development.
2020-07-03 16:56:44 +09:00
Koichi Sasada 8655c2e690
RUBY_DEBUG_LOG: Logging debug information mechanism (#3279)
* RUBY_DEBUG_LOG: Logging debug information mechanism

This feature provides a mechanism to store logging information
to a file, stderr or memory space with simple macros.

The following information will be stored.
  * (1) __FILE__, __LINE__ in C
  * (2) __FILE__, __LINE__ in Ruby
  * (3) __func__ in C (message title)
  * (4) given string with sprintf format
  * (5) Thread number (if multiple threads are running)

This feature is enabled only USE_RUBY_DEBUG_LOG is enabled.
Release version should not enable it.

Running with the `RUBY_DEBUG_LOG` environment variable enables
this feature.

  # logging into a file
  RUBY_DEBUG_LOG=/path/to/file STDERR

  # logging into STDERR
  RUBY_DEBUG_LOG=stderr

  # logging into memory space (check with a debugger)
  # It will help if the timing is important.
  RUBY_DEBUG_LOG=mem

RUBY_DEBUG_LOG_FILTER environment variable can specify the fileter string.
If "(3) __func__ in C (message title)" contains the specified string, the
infomation will be stored (example: RUBY_DEBUG_LOG_FILTER=str will enable
only on str related information).

In a MRI source code, you can use the following macros:
  * RUBY_DEBUG_LOG(fmt, ...): Above (1) to (4) will be logged.
  * RUBY_DEBUG_LOG2(file, line, fmt, ...):
    Same as RUBY_DEBUG_LOG(), but (1) will be replaced with given file, line.
2020-07-03 16:55:54 +09:00
Hiroshi SHIBATA 01776ca1c0 Ignore conftest.c under the ext directories for CodeQL analysis 2020-07-03 15:16:55 +09:00
Yusuke Endoh 1e039474a2 test/json/json_fixtures_test.rb: Prevent an "out of range" warning
```
/home/mame/work/ruby/.ext/common/json/common.rb:263: warning: Float 23456789012E666 out of range
```
2020-07-03 11:47:09 +09:00
git 05a12297c3 * 2020-07-03 [ci skip] 2020-07-03 11:27:07 +09:00
Yusuke Endoh e6a8590aa4 Reintroduce c565dfb09a 2020-07-03 11:05:08 +09:00
Hiroshi SHIBATA 59ded36c60
Expose `assert_pattern_list` for drb test with test-unit gem. 2020-07-02 20:53:42 +09:00
git 08ba5bec2b * 2020-07-02 [ci skip] 2020-07-02 14:34:56 +09:00
卜部昌平 bf3f03c925 integer.rbinc: do not generate C functions
This changeset changes for instance Integer#integer? from:

    == disasm: #<ISeq:to_i@<internal:integer>:66 (66,2)-(69,5)> (catch: FALSE)
    0000 opt_invokebuiltin_delegate_leave       <builtin!_bi7/0>, 0       (68)[LiCa]
    0003 leave                                                            (69)[Re]

to:

    == disasm: #<ISeq:to_i@<internal:integer>:66 (66,2)-(69,5)> (catch: FALSE)
    0000 putself                                                          (68)[LiCa]
    0001 leave                                                            (69)[Re]

which is of course faster.
2020-07-02 14:34:30 +09:00
Nobuyoshi Nakada 49029811d9
Reduced working `Rational` object allocations
When rationalizing negative values.
2020-07-01 22:41:16 +09:00
Nobuyoshi Nakada 254bed3027
Renamed `nurat_sub` compliant with `rb_rational_plus` 2020-07-01 22:41:15 +09:00
Nobuyoshi Nakada 53d2bfd540
Added a few integer case short-circuits 2020-07-01 22:41:15 +09:00
Nobuyoshi Nakada 29ecce4d72
Replaced f_odd_p with rb_int_odd_p 2020-07-01 22:41:14 +09:00
git 68d7e93b3b * 2020-07-01 [ci skip] 2020-07-01 18:51:19 +09:00
Hiroshi SHIBATA 0aac138e0b
Merge json-2.3.1 from flori/json 2020-07-01 18:50:39 +09:00
Marc-Andre Lafortune 26041da2fb
[flori/json] Typo fix
https://github.com/flori/json/commit/26c1769969
2020-07-01 18:47:51 +09:00
BurdetteLamar d69b55ac05
[flori/json] Added :call-seq: to RDOc for some methods
https://github.com/flori/json/commit/ee5b6a74e9
2020-07-01 18:47:51 +09:00
Watson cb3e62511c
[flori/json] Use frozen string for hash key
When use non-frozen string for hash key with `rb_hash_aset()`, it will duplicate and freeze it internally.
To avoid duplicate and freeze, this patch will give a frozen string in `rb_hash_aset()`.

```
Warming up --------------------------------------
                json    14.000  i/100ms
Calculating -------------------------------------
                json    148.844  (± 1.3%) i/s -    756.000  in   5.079969s
```

```
Warming up --------------------------------------
                json    16.000  i/100ms
Calculating -------------------------------------
                json    165.608  (± 1.8%) i/s -    832.000  in   5.025367s
```

```
require 'json'
require 'securerandom'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj << {
    "id": i,
    "uuid": SecureRandom.uuid,
    "created_at": Time.now
  }
end

json = obj.to_json

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count < iter
      JSON.parse(json)
      count += 1
    end
  end
end
```

https://github.com/flori/json/commit/18292c0c1d
2020-07-01 18:47:51 +09:00
BurdetteLamar 7d8ce96de6
[flori/json] RDoc enhancements
https://github.com/flori/json/commit/ada48f0236
2020-07-01 18:47:51 +09:00
BurdetteLamar be6447381c
[flori/json] RDoc enhancements
https://github.com/flori/json/commit/470d909c0d
2020-07-01 18:47:51 +09:00
BurdetteLamar 99980b3034
[flori/json] RDoc enhancements
https://github.com/flori/json/commit/7bee2c7c13
2020-07-01 18:47:51 +09:00
Marc-Andre Lafortune fe10323a35
[flori/json] Fix test that wasn't testing anything
https://github.com/flori/json/commit/d5c6566b41
2020-07-01 18:47:51 +09:00
BurdetteLamar 4689fd5f99
[flori/json] Rdoc enhancements
https://github.com/flori/json/commit/e7e3732130
2020-07-01 18:47:50 +09:00
Nobuyoshi Nakada 1351374bd1
Split visibility cases 2020-06-30 19:12:05 +09:00
Nobuyoshi Nakada 52ef2477e4
Extracted METHOD_ENTRY_CACHEABLE macro 2020-06-30 19:12:02 +09:00
Nobuyoshi Nakada 74ac12830b
Evaluate macros argument just once 2020-06-30 19:12:00 +09:00
Samuel Giddins 7cb8904a12 Extract correct processor name for ARM64 Macs 2020-06-30 19:03:50 +09:00
git 15a312ed40 * 2020-06-30 [ci skip] 2020-06-30 17:14:18 +09:00
Kazuhiro NISHIYAMA eefc2d8a3c
Fix a typo [ci skip] 2020-06-30 17:13:37 +09:00
Bart de Water 3621a7debf Avoid deprecated OpenSSL::Digest constants 2020-06-29 13:25:32 +09:00
卜部昌平 1ce9c37257 Revert "RBIMPL_UNREACHABLE_RETURN: evaluate the argument"
This reverts commit c8dc2bf140.

No longer necessary.
2020-06-29 12:33:17 +09:00
卜部昌平 94ab244b43 rb_class_modify_check: add UNREACHABLE
(I was not aware of this because I use clang, but) it seems gcc cannot
detect reachablility of this point.  It renders an unused variable
warning, which is a false positive.  Let us suppress the compiler.

https://github.com/ruby/ruby/runs/816997191#step:9:62
2020-06-29 11:43:48 +09:00
git 1020e120e0 * 2020-06-29 [ci skip] 2020-06-29 11:06:18 +09:00
卜部昌平 a523eca1c2 rb_enc_symname_type: refactor split
Reduce goto by splitting the function.
2020-06-29 11:05:41 +09:00
卜部昌平 2bd0f37e2b glob_opendir: move cleanup codes at the end
Nobu likes this arrangement.
2020-06-29 11:05:41 +09:00
卜部昌平 da8af471fb find_time_t: reset status before goto 2020-06-29 11:05:41 +09:00
卜部昌平 de3e931df7 add UNREACHABLE_RETURN
Not every compilers understand that rb_raise does not return.  When a
function does not end with a return statement, such compilers can issue
warnings.  We would better tell them about reachabilities.
2020-06-29 11:05:41 +09:00
卜部昌平 c8dc2bf140 RBIMPL_UNREACHABLE_RETURN: evaluate the argument
Prevent casual typos inside of UNREACHABLE_RETURN(...).
2020-06-29 11:05:41 +09:00
卜部昌平 bacd03ebdf compile_redo: fix wrong condition 2020-06-29 11:05:41 +09:00
卜部昌平 2b636dc81d make_exception: early return
The rb_exc_new3() result is already ready to be returned.  No need to
fall through the switch.
2020-06-29 11:05:41 +09:00