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

57916 Коммитов

Автор SHA1 Сообщение Дата
Jeremy Evans 1d5066efb0 Make m(**{}) mean call without keywords
Previously, **{} was removed by the parser:

```
$ ruby --dump=parse -e '{**{}}'
 @ NODE_SCOPE (line: 1, location: (1,0)-(1,6))
 +- nd_tbl: (empty)
 +- nd_args:
 |   (null node)
 +- nd_body:
     @ NODE_HASH (line: 1, location: (1,0)-(1,6))*
     +- nd_brace: 1 (hash literal)
     +- nd_head:
         (null node)
```

Since it was removed by the parser, the compiler did not know
about it, and `m(**{})` was therefore treated as `m()`.

This modifies the parser to not remove the `**{}`.  A simple
approach for this is fairly simple by just removing a few
lines from the parser, but that would cause two hash
allocations every time it was used.  The approach taken here
modifies both the parser and the compiler, and results in `**{}`
not allocating any hashes in the usual case.

The basic idea is we use a literal node in the parser containing
a frozen empty hash literal.  In the compiler, we recognize when
that is used, and if it is the only keyword present, we just
push it onto the VM stack (no creation of a new hash or merging
of keywords).  If it is the first keyword present, we push a
new empty hash onto the VM stack, so that later keywords can
merge into it.  If it is not the first keyword present, we can
ignore it, since the there is no reason to merge an empty hash
into the existing hash.

Example instructions for `m(**{})`

Before (note ARGS_SIMPLE):

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 opt_send_without_block       <callinfo!mid:m, argc:0, FCALL|ARGS_SIMPLE>, <callcache>
0004 leave
```

After (note putobject and KW_SPLAT):

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 putobject                    {}
0003 opt_send_without_block       <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0006 leave
```

Example instructions for `m(**h, **{})`

Before and After (no change):

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 putspecialobject             1
0003 newhash                      0
0005 putself
0006 opt_send_without_block       <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0009 opt_send_without_block       <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache>
0012 opt_send_without_block       <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0015 leave
```

Example instructions for `m(**{}, **h)`

Before:

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 putspecialobject             1
0003 newhash                      0
0005 putself
0006 opt_send_without_block       <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0009 opt_send_without_block       <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache>
0012 opt_send_without_block       <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0015 leave
```

After (basically the same except for the addition of swap):

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 newhash                      0
0003 putspecialobject             1
0005 swap
0006 putself
0007 opt_send_without_block       <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0010 opt_send_without_block       <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache>
0013 opt_send_without_block       <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0016 leave
```
2019-09-05 09:57:43 -07:00
Yusuke Endoh 433c9c00d9 Add a temporal stack dumper for debugging on trunk-mjit
This must be definitely removed after we collect the stack traces :-)
http://ci.rvm.jp/results/trunk-mjit@silicon-docker/2245710
2019-09-05 22:16:21 +09:00
yuuji.yaginuma 0036aa3532 Add version that FreeBSD supports `CLOCK_PROCESS_CPUTIME_ID` [ci skip]
Seems FreeBSD already supported `CLOCK_PROCESS_CPUTIME_ID`.
That added by https://reviews.freebsd.org/rS239347 and the doc was updated
by https://reviews.freebsd.org/rS315694.

I confirmed `CLOCK_PROCESS_CPUTIME_ID` constant exists in 9.3.0 branch.
https://github.com/freebsd/freebsd/blob/release/9.3.0/sys/sys/time.h#L269
2019-09-05 22:09:15 +09:00
David Rodríguez 1c4af1a77f
Add tests for `File.absolute_path?`
[Feature #15868]
2019-09-05 20:04:50 +09:00
David Rodríguez 2a166cfea2 Add `File.absolute_path?` (#2198)
In order to check whether a path is absolute or not in a portable way.

[Feature #15868]
2019-09-05 20:00:50 +09:00
David Rodríguez d9e6315177
[rubygems/rubygems] Bump rubocop to 0.74.0 and fix new offenses
https://github.com/rubygems/rubygems/commit/d4fc383497
2019-09-05 18:48:15 +09:00
Alexander Pakulov 0b9b0774c3 [rubygems/rubygems] Minor fix
https://github.com/rubygems/rubygems/commit/95c1f4e179
2019-09-05 18:44:02 +09:00
bronzdoc 565828a778 [rubygems/rubygems] Fix Layout/SpaceAroundOperators: Operator = should be surrounded by a single space.
https://github.com/rubygems/rubygems/commit/eaa38ebeb1
2019-09-05 18:43:45 +09:00
bronzdoc 73574756f9 [rubygems/rubygems] Add missing parentheses
https://github.com/rubygems/rubygems/commit/f5972338e0
2019-09-05 18:43:37 +09:00
bronzdoc 92be07b1e1 [rubygems/rubygems] Remove unnecessary gem_name method
https://github.com/rubygems/rubygems/commit/d1bb122651
2019-09-05 18:43:29 +09:00
bronzdoc b11cfed4c4 [rubygems/rubygems] Error out if there are multiple gemspecs and no gemspec is specified
https://github.com/rubygems/rubygems/commit/547947bbf0
2019-09-05 18:43:21 +09:00
bronzdoc 400d693863 [rubygems/rubygems] Remove useless gem setup
https://github.com/rubygems/rubygems/commit/c8913e37a7
2019-09-05 18:43:12 +09:00
bronzdoc 6cacbf542c [rubygems/rubygems] Test building a gem with multiple gemspec without a gem name specified
https://github.com/rubygems/rubygems/commit/38c72fd145
2019-09-05 18:43:04 +09:00
bronzdoc a02da1012b [rubygems/rubygems] Build the first gemspec we found if no gemspec is specified
https://github.com/rubygems/rubygems/commit/ab186266b7
2019-09-05 18:42:56 +09:00
bronzdoc bcf51dd763 [rubygems/rubygems] Improve gemspec assignment and error message
https://github.com/rubygems/rubygems/commit/dc70c5a192
2019-09-05 18:42:49 +09:00
bronzdoc 68937fe0e4 [rubygems/rubygems] Make passing a gem name to be optional
https://github.com/rubygems/rubygems/commit/4ba4ffebbe
2019-09-05 18:42:41 +09:00
bronzdoc 95326150fa [rubygems/rubygems] Move build gem logic to its own method
https://github.com/rubygems/rubygems/commit/a16eacd650
2019-09-05 18:42:33 +09:00
David Rodríguez fea91d69a3 [rubygems/rubygems] Don't fail when `uninstall --all` with default gem
Instead, display an informative message saying that uninstallation of
specific versions is being skipped because of being default gems.

https://github.com/rubygems/rubygems/commit/b44845aa1d
2019-09-05 18:42:26 +09:00
David Rodríguez f9f6a3d793 [rubygems/rubygems] Little refactor to avoid rubocop's false positive
Otherwise it detects duplicate methods here, because it doesn't see that
we are reopening the class in two different places.

https://github.com/rubygems/rubygems/commit/ae3fb47f5f
2019-09-05 18:42:18 +09:00
Alexander Pakulov d84b9b6d0a [rubygems/rubygems] Use IAM role to extract security-credentials for EC2 instance
https://github.com/rubygems/rubygems/commit/9a401646e1
2019-09-05 18:41:58 +09:00
David Rodríguez d219be4a1c [rubygems/rubygems] Move empty check earlier
https://github.com/rubygems/rubygems/commit/fc224e9717
2019-09-05 18:41:49 +09:00
Kazuhiro NISHIYAMA 7a2bd91ed2
Try to fix `invalid option`
https://github.com/ruby/ruby/runs/212727409#step:11:67
```
invalid option: -j5
```
2019-09-05 17:51:02 +09:00
Kazuhiro NISHIYAMA f4df9fb46b
Change name to `Tests (test-bundled-gems)` in macos.yml too 2019-09-05 17:47:51 +09:00
卜部昌平 436099ee04 add tests
Some coverage improvements.
2019-09-05 15:02:44 +09:00
Nobuyoshi Nakada 8a608f1b1f
Removed -git option of make-snapshot
Git is not for direct access to a remote repository.
Most of its operations need a local clone.
2019-09-05 14:39:53 +09:00
卜部昌平 41bc766763 interesting (but annoying) tidbit warning suppressed
This changeset is to suppress clang's -Wimplicit-int-float-conversion
warning.

In 64 bit signed long and IEEE 754 double combination (== almost
everyone these days), LONG_MAX is 9,223,372,036,854,775,807.  This
value is _not_ exactly representable by double.  The nearest value
that a double can represnt is 9,223,372,036,854,775,808. It is one
greater than LONG_MAX.  Let's call this value the "x".

The expression `LONG_MAX < yi` is a long versus double comparison.
According to ISO/IEC 9899:1999 Section 6.3.1.8 (that defines the
"usual rithmetic conversions"), The long value must first be casted
into double.  Because FLT_ROUNDS is typically 1 ("round to the
nearest" mode), the conversion yields the "x" value shown above.  So
the comparison is in fact `x < yi`.

This comparison is false for yi == x situation, i.e. yi is still
bigger than LONG_MAX.  On such situation the `yn = (long)yi;`
statement that appear several lines below renders underfined
behaviour, as per ISO/IEC 9899:1999 Section 6.3.1.3.

To remedy, we just change the comparison from `<` to `<=` so that
yi == x situation can properly be handled.
2019-09-05 14:29:11 +09:00
卜部昌平 dd2b9d4a96 hide rb_funcallv_with_cc from public
Requested by ko1.  Also, because now that this function is internal
use only, why not just directly use struct rb_call_cache to purge
the ZALLOC.
2019-09-05 12:13:07 +09:00
卜部昌平 b005d7c2e2 use existing vm_search_method()
Ko1 plans to implement Guild.  That can interface the caching
mechanism introduced here.  To prevent future breakage we would
better avoid rolling our own code here.  Instead use the existing
vm_search_method() which would be modified by him.

This commit deletes some asserions, but they are in fact checked
inside of vm_search_method().
2019-09-05 11:58:39 +09:00
git 7a1f650c13 * 2019-09-05 [ci skip] 2019-09-05 08:33:02 +09:00
Nobuyoshi Nakada 9f59d30daa
Separate VCS::DEBUG_OUT 2019-09-05 00:33:49 +09:00
Akinori MUSHA f6da4a5447
Describe #eager in the Enumerator::Lazy section 2019-09-04 16:16:47 +09:00
Akinori MUSHA 1d4bd229b8
Implement Enumerator::Lazy#eager [Feature #15901] 2019-09-04 16:16:46 +09:00
Urabe, Shyouhei 2a6457b5b7 add rb_funcallv_with_cc()
Why not cache the method entry at each caller site.  The void**
is in fact a method entry, but this struct is hidden from ruby.h
so intentionally left opaque.
2019-09-04 14:08:40 +09:00
Kazuhiro NISHIYAMA ccad34f453
Add TEST_BUNDLED_GEMS_ALLOW_FAILURES=minitest 2019-09-04 12:51:39 +09:00
Kazuhiro NISHIYAMA 967ef0d4f6
Use `git pull` instead of `git fetch` if master branch 2019-09-04 12:46:26 +09:00
Kazuhiro NISHIYAMA 1e30d0af7d
`$JOBS` does not set in `env:` 2019-09-04 12:03:28 +09:00
Kazuhiro NISHIYAMA b0d0b850bc
Use RUBY_TESTOPTS instead of TESTOPTS
https://github.com/ruby/ruby/pull/2417#issuecomment-526884646
> `TESTOPTS` is defaulted to `$(RUBY_TESTOPTS)` in `common.mk` file.
> Use the latter name to pass options via an environment variable.
2019-09-04 11:50:37 +09:00
Takashi Kokubun c14b67b2a8
Check frozen flag on MJIT setinstancevariable
It does not seem to have a significant performance impact, hopefully?

```
$ benchmark-driver -v benchmark.yml --rbenv 'before --jit;after --jit' --repeat-count=24 --output=all
before --jit: ruby 2.7.0dev (2019-09-03T21:02:24Z master 77596fb7a9) +JIT [x86_64-linux]
after --jit: ruby 2.7.0dev (2019-09-04T01:54:44Z master 7363e22d79) +JIT [x86_64-linux]
Calculating -------------------------------------
                                 before --jit           after --jit
Optcarrot Lan_Master.nes    48.44054595799523     71.67010255902900 fps
                            71.32797692837639     71.97846863769546
                            72.51921961607691     78.87360980544105
                            73.54082925611047     79.80408132389941
                            74.03503843709451     79.85739528572826
                            74.04863857926493     79.89850834901381
                            75.30266276129467     80.34607233076015
                            75.69063990896244     80.88474397425360
                            75.70458132587405     81.09234267781642
                            77.39842764662852     82.13766823612643
                            77.76922944068329     82.20398304840373
                            81.17984044023393     82.26722630628272
                            82.85235776076533     82.71375902781254
                            83.04906099135320     82.75893420702198
                            83.10214168136230     82.79668965325972
                            83.71456007558125     82.85131667916379
                            84.06658306760725     82.95676565411722
                            84.25690684305728     83.19972846225775
                            84.27938663923503     83.28510503845854
                            84.45467716218090     83.41003730434703
                            84.51563186125925     83.67773614721280
                            84.56139892968321     84.02082201151110
                            84.69819452180658     84.10495346787033
                            84.78125989622576     84.47867803506055
```

Note for backporter:
test_jit's `success_count` would be 1 in Ruby 2.6, since 2.7 introduced
"MJIT recompile" on JIT-ed code cancel.

[Bug #16139]
2019-09-04 11:10:21 +09:00
Jeremy Evans 77596fb7a9
Do not turn on keyword_init for Struct subclass if keyword hash is empty
This was accidentally turned on because there was no checking for
Qundef.

Also, since only a single keyword is currently supported, simplify
the rb_get_kwargs call.
2019-09-03 14:02:24 -07:00
Jeremy Evans 39c3252cd1
Merge pull request #2422 from jeremyevans/rb_keyword_given_p
Add rb_keyword_given_p to the C-API
2019-09-03 11:32:02 -07:00
git f702cd6ace * 2019-09-04 [ci skip] 2019-09-04 03:31:11 +09:00
Jeremy Evans a7d7a0df91 Fix Enumerator::Lazy#{to_enum,enum_for} where method is defined in Lazy
Previously, passing to_enum/enum_for a method that was defined in
Lazy itself returned wrong results:

  [1,2,3].to_enum(:map).to_a
  # => [1, 2, 3]
  [1,2,3].lazy.to_enum(:map).to_a
  # => []

I'm not sure why methods that are designed to be lazy do not work
with to_enum/enum_for.  However, one possible way to work around
this bug is to have to_enum/enum_for use the implementation found
in Enumerable/Enumerator, which is what this commit does.

While this commit works around the problem, it is a band-aid, not a
real fix.  It doesn't handle aliases of Enumerable::Lazy methods,
for instance.  A better fix would be appreciated.
2019-09-03 11:30:49 -07:00
Jeremy Evans 4a3972c261 Remove bad expectation in spec
This spec should not be checking where methods are defined, only
that the method works as expected (returns a Lazy instance).
2019-09-03 11:30:49 -07:00
Jeremy Evans e94ac03eb0 Make Enumerator::Lazy#with_index be lazy
Previously, Enumerator::Lazy#with_index was not defined, so it
picked up the default implementation from Enumerator, which was
not lazy.

Based on earlier patch from nobu.

Fixes [Bug #7877]
2019-09-03 11:30:49 -07:00
Takashi Kokubun fb67d4fc77
Move an unstable bootstraptest to pending
This has been unstable on AppVeyor mswin since the introduction
3fd83cb6fc.
https://ci.appveyor.com/project/ruby/ruby/builds/27103307/job/j7xwjmsos2k22cck

Let's have it in pending.rb to be fixed.
2019-09-03 21:49:52 +09:00
Takashi Kokubun ecc37ee67b
Stop testing inexistent instructions 2019-09-03 21:38:32 +09:00
Takashi Kokubun beaabd2308
Unify SUPPORT_JOKE and OPT_SUPPORT_JOKE
for simplicity and consistency.

Now SUPPORT_JOKE needs to be prefixed with OPT_ to make the config
visible in `RubyVM::VmOptsH`, and the inconsistency was introduced.

As it has never been available for override in configure (no #ifndef
guard), it should be fine to rename the config.
2019-09-03 21:12:31 +09:00
Takashi Kokubun 7cb19b3f5b
Roughly retry choco install commands
to deal with random failures:
https://github.com/ruby/ruby/runs/210617845
2019-09-03 21:03:11 +09:00
Takashi Kokubun afe8bf2489
Try extending timeout of IO.select
hoping to stabilize:
https://app.wercker.com/ruby/ruby/runs/mjit-test1/5d6df8a8a952c20008acf75b?step=5d6df90e4971a6000714c627
2019-09-03 20:34:52 +09:00
Kazuhiro NISHIYAMA 36a0c668b6
Remove SKIP_DOXYGEN because job.env does not set in `if:` 2019-09-03 18:36:08 +09:00