Alan Wu
050b932152
Iseq#to_binary: Add support for NoMatchingPatternError and TypeError
...
Binary dumping the iseq for `case foo in []; end` used to crash as
there was no handling for these exception classes.
Pattern matching generates these classes as operands to `putobject`.
[Bug #16088 ]
Closes: https://github.com/ruby/ruby/pull/2325
2019-08-09 01:29:53 +09:00
Nobuyoshi Nakada
830fd04181
C99 allows trailing comma in enum
2019-08-09 01:27:52 +09:00
Yusuke Endoh
086ffe72c7
Revert "Revert "Add a specialized instruction for .nil?
calls""
...
This reverts commit a0980f2446
.
Retry for macOS Mojave.
2019-08-02 23:25:38 +09:00
Yusuke Endoh
a0980f2446
Revert "Add a specialized instruction for .nil?
calls"
...
This reverts commit 9faef3113f
.
It seemed to cause a failure on macOS Mojave, though I'm unsure how.
20190802
T034503Z.fail.html.gz
This tentative revert is to check if the issue is actually caused by the
change or not.
2019-08-02 15:03:34 +09:00
git
714924fd34
* expand tabs.
2019-08-01 08:21:58 +09:00
Aaron Patterson
9faef3113f
Add a specialized instruction for .nil?
calls
...
This commit adds a specialized instruction for called to `.nil?`. It is
about 27% faster than master in the case where the object is nil or not
nil. In the case where an object implements `nil?`, I think it may be
slightly slower. Here is a benchmark:
```ruby
require "benchmark/ips"
class Niller
def nil?; true; end
end
not_nil = Object.new
xnil = nil
niller = Niller.new
Benchmark.ips do |x|
x.report("nil?") { xnil.nil? }
x.report("not nil") { not_nil.nil? }
x.report("niller") { niller.nil? }
end
```
On Ruby master:
```
[aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 429.195k i/100ms
not nil 437.889k i/100ms
niller 437.935k i/100ms
Calculating -------------------------------------
nil? 20.166M (± 8.1%) i/s - 100.002M in 5.002794s
not nil 20.046M (± 7.6%) i/s - 99.839M in 5.020086s
niller 22.467M (± 6.1%) i/s - 112.111M in 5.013817s
[aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 449.660k i/100ms
not nil 433.836k i/100ms
niller 443.073k i/100ms
Calculating -------------------------------------
nil? 19.997M (± 8.8%) i/s - 99.375M in 5.020458s
not nil 20.529M (± 7.0%) i/s - 102.385M in 5.020689s
niller 21.796M (± 8.0%) i/s - 108.110M in 5.002300s
[aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 402.119k i/100ms
not nil 438.968k i/100ms
niller 398.226k i/100ms
Calculating -------------------------------------
nil? 20.050M (±12.2%) i/s - 98.519M in 5.008817s
not nil 20.614M (± 8.0%) i/s - 102.280M in 5.004531s
niller 22.223M (± 8.8%) i/s - 110.309M in 5.013106s
```
On this branch:
```
[aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 468.371k i/100ms
not nil 456.517k i/100ms
niller 454.981k i/100ms
Calculating -------------------------------------
nil? 27.849M (± 7.8%) i/s - 138.169M in 5.001730s
not nil 26.417M (± 8.7%) i/s - 131.020M in 5.011674s
niller 21.561M (± 7.5%) i/s - 107.376M in 5.018113s
[aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 477.259k i/100ms
not nil 428.712k i/100ms
niller 446.109k i/100ms
Calculating -------------------------------------
nil? 28.071M (± 7.3%) i/s - 139.837M in 5.016590s
not nil 25.789M (±12.9%) i/s - 126.470M in 5.011144s
niller 20.002M (±12.2%) i/s - 98.144M in 5.001737s
[aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 467.676k i/100ms
not nil 445.791k i/100ms
niller 415.024k i/100ms
Calculating -------------------------------------
nil? 26.907M (± 8.0%) i/s - 133.755M in 5.013915s
not nil 25.319M (± 7.9%) i/s - 125.713M in 5.007758s
niller 19.569M (±11.8%) i/s - 96.286M in 5.008533s
```
Co-Authored-By: Ashe Connor <kivikakk@github.com>
2019-07-31 16:21:25 -07:00
Jeremy Evans
aa97410b0a
Warn if using return at top-level with an argument
...
Fixes [Bug #14062 ]
2019-07-29 09:01:23 -07:00
git
bdec1ad9a9
* expand tabs.
2019-07-17 23:42:21 +09:00
Yusuke Endoh
416ead4cda
compile.c: add NO_CHECK for the calls to COMPILE whose result is unused
...
to suppress many warnings of Coverity Scan
2019-07-17 23:41:58 +09:00
git
a8e4b7b12f
* expand tabs.
2019-07-16 07:19:52 +09:00
Yusuke Endoh
c184a1c261
compile.c: add NO_CHECK for the calls to COMPILE whose result is unused
...
to suppress many warnings of Coverity Scan
2019-07-16 07:18:54 +09:00
Yusuke Endoh
6aab77a7a3
Add a /* fall through */ comment
2019-07-16 07:17:57 +09:00
git
f103ed8b7d
* expand tabs.
2019-07-15 14:43:39 +09:00
Yusuke Endoh
4b345f9d4b
compile.c: ignore the result of COMPILE by marking with NO_CHECK
...
to suppress many warnings of Coverity Scan
2019-07-15 14:43:24 +09:00
Yusuke Endoh
c9a59f491d
Add a /* fall through */ comment
2019-07-15 07:59:11 +09:00
Yusuke Endoh
772dae8bef
Add a /* fall through */ comment
2019-07-15 07:57:07 +09:00
Yusuke Endoh
3201062adf
Add a /* fall through */ comment
2019-07-15 00:31:07 +09:00
Yusuke Endoh
970c12551e
Add a /* fall through */ comment
2019-07-15 00:30:35 +09:00
Yusuke Endoh
09187c64b8
Add a /* fall through */ comment
2019-07-15 00:10:39 +09:00
git
83153bbb14
* expand tabs.
2019-07-14 16:18:48 +09:00
Yusuke Endoh
73fab16e76
compile.c (defined_expr): return void instead of int
...
It always returned 1.
2019-07-14 16:18:32 +09:00
Jeremy Evans
f296c260ef
Fix segfault when using method reference operator without using result
...
Fixes [Bug #15985 ]
2019-07-05 20:43:38 -07:00
git
d4929f5185
* expand tabs.
2019-06-16 23:01:46 +09:00
Yusuke Endoh
1ff26dc4c7
Revert "Make constant assignments more conforming to JIS X 3017:2013 11.4.2.2.3"
...
This reverts commit 44caca11cf
.
The change caused a build failure.
http://ci.rvm.jp/results/trunk-vm-asserts@silicon-docker/2102153
2019-06-16 23:00:05 +09:00
git
11f8c89171
* expand tabs.
2019-06-16 22:48:23 +09:00
Yuki Yugui Sonoda
44caca11cf
Make constant assignments more conforming to JIS X 3017:2013 11.4.2.2.3
...
compile.c (NODE_CDECL): Evaluate the module before the value
test/ruby/test_const.rb (test_evaluation_order): added a test case
2019-06-16 22:43:03 +09:00
Kazuki Tsujimoto
be6b462489
Use checktype for performance
2019-06-11 00:20:10 +09:00
Yusuke Endoh
a6a26e42b1
compile.c: Partially revert r63870 which caused wrong optimization
...
[Bug #15906 ]
2019-06-07 14:46:59 +09:00
Martin Dürst
f258137083
Fix grammar of macro name: ECCESSED -> ECCESSIVE
...
Fix the name of the macro variable introduced in 0872ea5330
from NODE_SPECIAL_EXCESSED_COMMA to NODE_SPECIAL_EXCESSIVE_COMMA.
2019-06-05 14:03:50 +09:00
git
b31e1b4a7c
* expand tabs.
2019-06-04 23:17:38 +09:00
Yusuke Endoh
0b0c6cb7e4
compile.c: Remove the magical (const NODE*) -1
...
It is used to represent "no default expression" for keyword argument:
`def foo(key:)`. This change uses NODE_SPECIAL_REQUIRED_KEYWORD.
2019-06-04 23:17:19 +09:00
Yusuke Endoh
0872ea5330
node.h: Avoid a magic number to represent excessed comma
...
`(ID)1` was assigned to NODE_ARGS#rest_arg for `{|x,| }`.
This change removes the magic number by introducing an explicit macro
variable for it: NODE_SPECIAL_EXCESSED_COMMA.
2019-06-04 23:17:18 +09:00
Nobuyoshi Nakada
b1aecef873
Use UNALIGNED_MEMBER_PTR
...
* internal.h (UNALIGNED_MEMBER_ACCESS, UNALIGNED_MEMBER_PTR):
moved from eval_intern.h.
* compile.c iseq.c, vm.c: use UNALIGNED_MEMBER_PTR for `entries`
in `struct iseq_catch_table`.
* vm_eval.c, vm_insnhelper.c: use UNALIGNED_MEMBER_PTR for `body`
in `rb_method_definition_t`.
2019-05-31 16:04:16 +09:00
git
f1b52d3a88
* expand tabs.
2019-05-05 11:13:54 +09:00
Nobuyoshi Nakada
ff21e75d32
parse.y: duplicated when clause warning
...
* parse.y (case_args): moved "duplicated when clause" warning from
compile phase, so that `ruby -wc` shows them.
2019-05-05 00:29:12 +09:00
Lourens Naudé
99084f5401
Lazy allocate the compile data catch table array
...
Closes: https://github.com/ruby/ruby/pull/2119
2019-04-25 12:37:29 +09:00
ktsj
eeee4f404b
Remove unnecessary condition
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-21 02:18:28 +00:00
ktsj
243842f68a
Avoid usage of the dummy empty BEGIN node
...
Use NODE_SPECIAL_NO_NAME_REST instead.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-20 03:37:22 +00:00
ktsj
9738f96fcf
Introduce pattern matching [EXPERIMENTAL]
...
[ruby-core:87945] [Feature #14912 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17 06:48:03 +00:00
nobu
025343654d
Get rid of a magic number
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-11 10:36:37 +00:00
nobu
47c82df27f
Share the exception local ID table
...
[Fix GH-2115]
From: Lourens Naudé <lourens@bearmetal.eu>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-11 10:36:36 +00:00
nobu
54b93ef1ac
compile.c: name a hidden local variable as a predefined ID
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 12:43:34 +00:00
kazu
25c1fd3b90
Reverting all commits from r67479 to r67496 because of CI failures
...
Because hard to specify commits related to r67479 only.
So please commit again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 09:15:21 +00:00
nobu
91db3b6c6b
compile.c: name a hidden local variable as a predefined ID
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 07:18:25 +00:00
nobu
9e448d2fd7
compile.c: cast iseqs to suppress warnings
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 01:18:01 +00:00
tenderlove
d099eabbb7
Set a write barrier between iseq and mark objects
...
ISeq pins references in the mark array during compile, so it manually
marks references in the mark_ary. This was causing write barrier
misses, so we need to add a write barrier when pushing on the mark
array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-09 23:48:17 +00:00
svn
4b53f84326
* expand tabs.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-05 08:15:21 +00:00
ko1
2b5bb8a087
add definemethod/definesmethod insn.
...
* insns.def: add definemethod and definesmethod (singleton method)
instructions. Old YARV contains these instructions, but it is moved
to methods of FrozenCore class because remove number of instructions
can improve performance for some techniques (static stack caching
and so on). However, we don't employ these technique and it is hard
to optimize/analysis definition sequence. So I decide to introduce
them (and remove definition methods). `putiseq` insn is also removed.
* vm_method.c (rb_scope_visibility_get): renamed to
`vm_scope_visibility_get()` and make it accept `ec`.
Same for `vm_scope_module_func_check()`.
These fixes are result of refactoring `vm_define_method`.
* vm_insnhelper.c (rb_vm_get_cref): renamed to `vm_get_cref`
because of consistency with other functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-05 08:15:11 +00:00
svn
d4f7fac6b8
* expand tabs.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-15 05:19:58 +00:00
mame
c36a6f97f2
node.h: introduce nd_brace to determine if a hash literal is a keyword
...
NODE_HASH#nd_brace is a flag that is 1 for `foo({ k: 1 })` and 0 for
`foo(k: 1)`.
nd_alen had been abused for the flag (and the implementation is
completely the same), but an explicit name is better to read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-15 05:19:54 +00:00