Jeremy Evans c20e819e8b Fix crash when passing large keyword splat to method accepting keywords and keyword splat
The following code previously caused a crash:

```ruby
h = {}
1000000.times{|i| h[i.to_s.to_sym] = i}
def f(kw: 1, **kws) end
f(**h)
```

Inside a thread or fiber, the size of the keyword splat could be much smaller
and still cause a crash.

I found this issue while optimizing method calling by reducing implicit
allocations.  Given the following code:

```ruby
def f(kw: , **kws) end
kw = {kw: 1}
f(**kw)
```

The `f(**kw)` call previously allocated two hashes callee side instead of a
single hash.  This is because `setup_parameters_complex` would extract the
keywords from the keyword splat hash to the C stack, to attempt to mirror
the case when literal keywords are passed without a keyword splat.  Then,
`make_rest_kw_hash` would build a new hash based on the extracted keywords
that weren't used for literal keywords.

Switch the implementation so that if a keyword splat is passed, literal keywords
are deleted from the keyword splat hash (or a copy of the hash if the hash is
not mutable).

In addition to avoiding the crash, this new approach is much more
efficient in all cases.  With the included benchmark:

```
                                1
            miniruby:   5247879.9 i/s
     miniruby-before:   2474050.2 i/s - 2.12x  slower

                        1_mutable
            miniruby:   1797036.5 i/s
     miniruby-before:   1239543.3 i/s - 1.45x  slower

                               10
            miniruby:   1094750.1 i/s
     miniruby-before:    365529.6 i/s - 2.99x  slower

                       10_mutable
            miniruby:    407781.7 i/s
     miniruby-before:    225364.0 i/s - 1.81x  slower

                              100
            miniruby:    100992.3 i/s
     miniruby-before:     32703.6 i/s - 3.09x  slower

                      100_mutable
            miniruby:     40092.3 i/s
     miniruby-before:     21266.9 i/s - 1.89x  slower

                             1000
            miniruby:     21694.2 i/s
     miniruby-before:      4949.8 i/s - 4.38x  slower

                     1000_mutable
            miniruby:      5819.5 i/s
     miniruby-before:      2995.0 i/s - 1.94x  slower
```
2024-02-11 22:48:38 -08:00
2023-11-14 16:22:03 -05:00
2024-02-11 20:55:26 +09:00
2023-11-23 17:17:28 +09:00
2024-01-13 11:08:03 +09:00
2024-02-08 14:43:56 +09:00
2024-02-08 14:17:01 +00:00
2024-01-08 15:51:15 -08:00
2024-01-12 16:13:42 -05:00
2024-02-08 14:36:29 -05:00
2024-02-04 16:43:09 +09:00
2023-11-23 02:15:42 +09:00
2024-02-12 01:09:51 +09:00
2024-01-13 11:08:00 +09:00
2024-02-09 14:20:17 +09:00
2024-01-08 00:50:41 +09:00
2024-01-22 19:39:34 +09:00
2023-12-19 13:09:36 -08:00
2024-01-30 14:48:59 +09:00
2024-01-08 00:50:41 +09:00
2024-01-10 16:21:55 -08:00
2024-01-24 20:51:50 +09:00
2023-11-14 15:56:57 +09:00
2023-12-18 20:17:43 +09:00
GPL
2024-01-30 14:48:59 +09:00
2024-02-09 12:08:54 -05:00
2024-01-31 13:41:36 -05:00
2024-01-31 13:41:36 -05:00
2024-01-19 10:25:02 -05:00
2024-01-19 10:25:02 -05:00
2023-12-07 15:52:35 -05:00
2024-02-09 14:20:17 +09:00
2024-01-14 17:55:11 +09:00
2024-01-06 13:25:17 -05:00
2024-02-10 18:58:42 +09:00
2023-12-15 11:58:43 +09:00
2024-01-30 14:48:59 +09:00
2024-01-30 14:48:59 +09:00
2024-01-13 23:43:07 +09:00
2023-12-27 19:31:56 -05:00
2024-01-19 10:25:02 -05:00
2024-01-19 10:25:02 -05:00
2023-11-03 10:41:48 +09:00
2023-12-22 22:18:14 -08:00
2024-02-08 14:36:39 -05:00
2023-12-04 13:57:12 -05:00
2024-02-09 11:09:56 +09:00
2024-02-08 10:49:38 -05:00
2023-11-14 15:56:57 +09:00
2024-01-31 10:47:35 -05:00
2024-01-17 13:17:25 -08:00
2024-01-23 01:42:32 +09:00
2023-12-02 21:48:00 +09:00
2023-12-02 21:48:00 +09:00
2023-12-07 15:52:35 -05:00
2024-01-30 14:48:59 +09:00
2023-12-07 15:52:35 -05:00
2023-12-15 13:42:19 -05:00
2023-11-23 17:17:28 +09:00
2024-01-30 14:48:59 +09:00
2024-01-19 10:25:02 -05:00
2023-12-07 09:23:02 -08:00
2024-01-30 14:48:59 +09:00
2024-02-10 14:24:28 +09:00

Actions Status: MinGW Actions Status: RJIT Actions Status: Ubuntu Actions Status: Windows AppVeyor status Travis Status

What is Ruby?

Ruby is an interpreted object-oriented programming language often used for web development. It also offers many scripting features to process plain text and serialized files, or manage system tasks. It is simple, straightforward, and extensible.

Features of Ruby

  • Simple Syntax
  • Normal Object-oriented Features (e.g. class, method calls)
  • Advanced Object-oriented Features (e.g. mix-in, singleton-method)
  • Operator Overloading
  • Exception Handling
  • Iterators and Closures
  • Garbage Collection
  • Dynamic Loading of Object Files (on some architectures)
  • Highly Portable (works on many Unix-like/POSIX compatible platforms as well as Windows, macOS, etc.) cf. https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers

How to get Ruby

For a complete list of ways to install Ruby, including using third-party tools like rvm, see:

https://www.ruby-lang.org/en/downloads/

You can download release packages and the snapshot of the repository. If you want to download whole versions of Ruby, please visit https://www.ruby-lang.org/en/downloads/releases/.

Download with Git

The mirror of the Ruby source tree can be checked out with the following command:

$ git clone https://github.com/ruby/ruby.git

There are some other branches under development. Try the following command to see the list of branches:

$ git ls-remote https://github.com/ruby/ruby.git

You may also want to use https://git.ruby-lang.org/ruby.git (actual master of Ruby source) if you are a committer.

How to build

See Building Ruby

Ruby home page

https://www.ruby-lang.org/

Documentation

Mailing list

There is a mailing list to discuss Ruby. To subscribe to this list, please send the following phrase:

join

in the mail subject (not body) to the address ruby-talk-request@ml.ruby-lang.org.

Copying

See the file COPYING.

Feedback

Questions about the Ruby language can be asked on the Ruby-Talk mailing list or on websites like https://stackoverflow.com.

Bugs should be reported at https://bugs.ruby-lang.org. Read "Reporting Issues" for more information.

Contributing

See "Contributing to Ruby", which includes setup and build instructions.

The Author

Ruby was originally designed and developed by Yukihiro Matsumoto (Matz) in 1995.

matz@ruby-lang.org

Description
Languages
Ruby 58.9%
C 29.7%
Rust 4%
C++ 3%
Makefile 2.1%
Other 2.2%