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

84217 Коммитов

Автор SHA1 Сообщение Дата
Peter Zhu 6da8f04e01 [ruby/irb] Escape closing square brackets in regexp
Fixes the following warning:

    test/irb/test_command.rb:546: warning: regular expression has ']' without escape

https://github.com/ruby/irb/commit/7efadc243b
2024-03-01 19:57:11 +00:00
Takashi Kokubun 70de3b170b
Optimize Hash methods with Kernel#hash (#10160) 2024-03-01 11:16:31 -08:00
Peter Zhu 6f31dd495c Don't check_rvalue_consistency in is_markable_object
is_markable_object is called by rb_objspace_markable_object_p, which
may pass a T_NONE object. check_rvalue_consistency will fail if a T_NONE
object is passed in.
2024-03-01 13:38:49 -05:00
Takashi Kokubun 661f9e6d03
YJIT: Support opt_invokebuiltin_delegate for leaf builtin (#10152) 2024-03-01 13:03:00 -05:00
Alan Wu 88050ec179 YJIT: No need to set cfp->sp when setting escaped locals
While writing to the env object can add it to the remember set,
it shouldn't trigger a GC run.
2024-03-01 12:54:34 -05:00
Stan Lo 57ca5960ad [ruby/irb] Restructure workspace management
(https://github.com/ruby/irb/pull/888)

* Remove dead irb_level method

* Restructure workspace management

Currently, workspace is an attribute of IRB::Context in most use cases.
But when some workspace commands are used, like `pushws` or `popws`, a
workspace will be created and used along side with the original workspace
attribute.

This complexity is not necessary and will prevent us from expanding
multi-workspace support in the future.

So this commit introduces a @workspace_stack ivar to IRB::Context so IRB
can have a more natural way to manage workspaces.

* Fix pushws without args

* Always display workspace stack after related commands are used

https://github.com/ruby/irb/commit/61560b99b3
2024-03-01 15:51:29 +00:00
Peter Zhu 162e13c884 Remove pointer check in vm_ccs_free
We don't need to check that the object is pointer to the GC heap in
vm_ccs_free because it is called during sweeping, which does not free
pages so it can never point to an object that is not on the GC heap.
2024-03-01 10:39:51 -05:00
Jean Boussier f3af5ae7e6 Make Struct memory leak test faster
[Bug #20311]

It times out on some platform, so we can reduce iterations.
On my machine it completes in 250ms and RSS grows 8X.
2024-03-01 16:33:09 +01:00
Jeremy Evans 334e4c65b3 Fix a couple issues noticed by nobu
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-03-01 07:10:25 -08:00
Jeremy Evans f446d68ba6 Add benchmarks for super and zsuper calls of different types
These show gains from the recent optimization commits:

```
                        arg_splat
            miniruby:   7346039.9 i/s
     miniruby-before:   4692240.8 i/s - 1.57x  slower

                  arg_splat_block
            miniruby:   6539749.6 i/s
     miniruby-before:   4358063.6 i/s - 1.50x  slower

                   splat_kw_splat
            miniruby:   5433641.5 i/s
     miniruby-before:   3851048.6 i/s - 1.41x  slower

             splat_kw_splat_block
            miniruby:   4916137.1 i/s
     miniruby-before:   3477090.1 i/s - 1.41x  slower

                   splat_kw_block
            miniruby:   2912829.5 i/s
     miniruby-before:   2465611.7 i/s - 1.18x  slower

                   arg_splat_post
            miniruby:   2195208.2 i/s
     miniruby-before:   1860204.3 i/s - 1.18x  slower
```

zsuper only speeds up in the post argument case, because
it was already set to use splatarray false in cases where
there were no post arguments.
2024-03-01 07:10:25 -08:00
Jeremy Evans 73371450c3 Avoid 1-2 array allocations for zsuper calls with post arguments
These previously resulted in 2 array allocations, one for newarray
and one for concatarray.  This replaces newarray and concatarray
with pushtoarray, and changes splatarray false to splatarray true,
which reduces it to 1 array allocation, in splatarray true.

This also sets VM_CALL_ARGS_SPLAT_MUT, so if the super method
accepts a positional splat, this will avoid an additional array
allocation on the callee side.
2024-03-01 07:10:25 -08:00
Jeremy Evans 32c58753af Fix splatarray false peephole optimization for f(*ary, **kw, &block)
This optimization stopped being using when the splatkw VM instruction
was added.  This change allows the optimization to apply again. This
also optimizes the following cases:

  super(*ary, **kw, &block)
  f(...)
  super(...)
2024-03-01 07:10:25 -08:00
Jeremy Evans e484ffaf20 Perform splatarray false peephole optimization for invokesuper in addition to send
This optimizes cases such as:

  super(arg, *ary)
  super(arg, *ary, &block)
  super(*ary, **kw)
  super(*ary, kw: 1)
  super(*ary, kw: 1, &block)

The super(*ary, **kw, &block) case does not use the splatarray false
optimization.  This is also true of the send case, since the
introduction of the splatkw VM instruction.  That will be fixed in
a later commit.
2024-03-01 07:10:25 -08:00
Jun Aruga 54d26221b4 .travis.yml: Allow failures for ppc64le and s390x.
Because Travis ppc64le/s390x are unstable.

ppc64le:
* https://app.travis-ci.com/github/ruby/ruby/builds/269211469
* https://app.travis-ci.com/github/ruby/ruby/builds/269204073

s390x:
* https://app.travis-ci.com/github/ruby/ruby/builds/269201221
2024-03-01 13:14:16 +01:00
Jean Boussier c09e5ad17d Clarify C API documentation about pinned classes
They are not only pinned, but also immortal. Even if the
constant referencing them is removed, they will remain alive.

It's a precision worth noting.
2024-03-01 08:24:16 +01:00
Jean Boussier e626da82ea Don't pin named structs defined in Ruby
[Bug #20311]

`rb_define_class_under` assumes it's called from C and that the
reference might be held in a C global variable, so it adds the
class to the VM root.

In the case of `Struct.new('Name')` it's wasteful and make
the struct immortal.
2024-03-01 08:23:38 +01:00
Nobuyoshi Nakada 5d76fe6b2a [ruby/optparse] Invoke pager for `--help`
https://github.com/ruby/optparse/commit/77dccce37c
2024-03-01 07:10:08 +00:00
Nobuyoshi Nakada 9b75e5f085
Add an example for fallback to sh 2024-03-01 13:56:52 +09:00
Nobuyoshi Nakada 5baee82c76
[DOC] Mention about executable file and fallback to sh 2024-03-01 13:11:29 +09:00
Nobuyoshi Nakada 1a9a20cebd
Turn `rb_sys_fail_on_write` into a function 2024-03-01 13:11:29 +09:00
Nobuyoshi Nakada 452d51ffe1
Use `File.open` and `File.write` instead of `Kernel#open` 2024-03-01 13:11:29 +09:00
git a465393cb9 Update bundled gems list at 874e9fc34d [ci skip] 2024-03-01 03:33:42 +00:00
dependabot[bot] 04a1b8739b Bump actions/cache from 4.0.0 to 4.0.1
Bumps [actions/cache](https://github.com/actions/cache) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](13aacd865c...ab5e6d0c87)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-29 19:33:26 -08:00
Hiroshi SHIBATA 874e9fc34d Don't need to remove ruby2_keywords dependency from drb 2024-03-01 12:32:40 +09:00
Hiroshi SHIBATA 1952c799af Bump up drb-2.2.1 2024-03-01 12:32:40 +09:00
dependabot[bot] b26602f828 Bump github/codeql-action from 3.24.5 to 3.24.6
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.5 to 3.24.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](47b3d888fe...8a470fddaf)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-29 19:32:28 -08:00
dependabot[bot] 8ec9c2dd16 Bump actions/cache in /.github/actions/setup/directories
Bumps [actions/cache](https://github.com/actions/cache) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](13aacd865c...ab5e6d0c87)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-29 19:23:05 -08:00
Kasumi Hanazuki 2508a79699 [ruby/resolv] Implement CAA resource record
This patch implements handling of CAA resource records defined by [RFC8659].

- There are no known deployment of CAA records outside of IN (Internet),
  but the RFC does not state that CAA records are class-specific.
  Thus `CAA` class is defined as a class-independent RRType.
- `CAA` class stores `flags` field (a 1-octet bitset) as an Integer.
  In this way it's easier to ensure the encoded RR is in the valid wire format.

[RFC8659]: https://datatracker.ietf.org/doc/html/rfc8659

https://github.com/ruby/resolv/commit/cfc4de75e3

Co-authored-by: aeris <aeris@imirhil.fr>
2024-02-29 20:55:26 +00:00
Peter Zhu d3ae5808bb Remove each_machine_stack_value
The function is only used by rb_gc_mark_machine_stack.
2024-02-29 14:26:31 -05:00
Benoit Daloze d5ae7965b7 [ruby/prism] Lazily create Location objects in Prism::Serialize::Loader#load_location
* Following the changes in #2428.
* PRISM_FFI_BACKEND=true ruby -v -Ilib -rprism -rbenchmark -e '10.times { p Benchmark.realtime { Dir.glob("lib/**/*.rb") { |f| Prism.parse_file(f) } } }'
  ruby 3.3.0:      0.255 => 0.210
  ruby 3.3.0 YJIT: 0.150 => 0.120

https://github.com/ruby/prism/commit/fabf809bbf
2024-02-29 19:24:04 +00:00
Benoit Daloze 6075f67ae6 [ruby/prism] Tweak wording for Prism::BACKEND
* TruffleRuby does support C extensions but FFI is faster there.

https://github.com/ruby/prism/commit/d211a87691
2024-02-29 19:24:04 +00:00
Takashi Kokubun 1a588922ae Load iseq name later than other ISEQ references
previous_insn_index() is crashing:
https://github.com/ruby/ruby/actions/runs/8100712618/job/22139323673
https://github.com/ruby/ruby/actions/runs/8099334388/job/22134848249

but it's probably not the fault of previous_insn_index() itself. I'm
guessing the top-most frame is a C frame, and so iseq is just 0.

To confirm that, I'd like to try calling other functions on an ISEQ
first.
2024-02-29 10:30:38 -08:00
Peter Zhu 3d61477900 Remove unused gc_mark_stack_values 2024-02-29 13:23:50 -05:00
Peter Zhu 6665ec26db Remove check for is_markable_object in gc_mark_stack_values
gc_mark_and_pin already checks for is_markable_object.
2024-02-29 13:23:50 -05:00
Yuta Saito 6e2880b388 [wasm-pic] Add `LDSHARED` definition for WASI platform
We are going to add dynamic linking support for WASI platform. The
`LDSHARED` definition is used to link shared libraries for building ruby
binaries and extensions.
2024-03-01 03:16:59 +09:00
Yuta Saito 57f014b2fa Use configured `LD` for linking enc and ext libraries
"AR" was well propagated to the enc.mk and mkmf, but "LD" was not. This
caused the dynamic libraries to be linked with a linker found in the PATH,
which could be different from the one used in the Ruby build process.
This is especially important for cross-compilation, where the host
linker may not be compatible with the target system. (e.g. WebAssembly)
2024-03-01 03:16:23 +09:00
Kevin Newton 1c0c490aa0 [ruby/prism] Warn on integers in flip-flops
https://github.com/ruby/prism/commit/500099e896
2024-02-29 17:32:37 +00:00
Kevin Newton f9d5c604c8 [PRISM] Use new command line option flags 2024-02-29 12:05:19 -05:00
Kevin Newton 50e999c56d [ruby/prism] Command line options as a bitset
https://github.com/ruby/prism/commit/369ffbd57e
2024-02-29 12:05:19 -05:00
Kevin Newton cd8d1018bb [ruby/prism] Resync RBI and test it in CI
https://github.com/ruby/prism/commit/4ef4032774
2024-02-29 16:29:16 +00:00
Takashi Kokubun 5891c70b38
YJIT: Support inlining putself (#10137) 2024-02-29 11:08:57 -05:00
Peter Zhu 4c0f0b90a4 Assume that FL_FINALIZE is in finalizer_table
If FL_FINALIZE is set but not in finalizer_table, then rb_bug.
2024-02-29 11:07:53 -05:00
Koichi ITO f8dd2342bf [ruby/prism] Fix an incorrect parsing for `Prism::Translation::Parser`
This PR fixes an incorrect parsing for `Prism::Translation::Parser`
when one-line pattern mathing with Ruby 2.7 runtime.

## Expected

Parsing should be done based on the specified Ruby parsing version,
independent of the Ruby runtime version. When parsing for Ruby 3.3,
it should return `:match_pattern_p` node:

```console
$ ruby -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("foo in bar")'
ruby 3.0.6p216 (2023-03-30 revision https://github.com/ruby/prism/commit/23a532679b) [x86_64-darwin19]
s(:match_pattern_p,
s(:send, nil, :foo),
  s(:match_var, :bar))
```

## Actual

When parsing with Ruby 2.7 runtime, `match_pattern` node is returned,
even though it is expected to parse for Ruby 3.3:

```console
$ ruby -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("foo in bar")'
ruby 2.7.8p225 (2023-03-30 revision https://github.com/ruby/prism/commit/1f4d455848) [x86_64-darwin19]
s(:match_pattern,
s(:send, nil, :foo),
  s(:match_var, :bar))
```

The cause was the use of `RUBY_VERSION` for condition logic,
which made it dependent on runtime Ruby version.
`Prism::Translation::Parser` supports parsing for Ruby 3.3+.
Therefore, the condition for parsing Ruby 2.7, which is not supported, is being removed.

## Background

Found due to incompatibility with RuboCop's `Layout/SpaceAroundKeyword` and `Style/TernaryParentheses` cops.

https://github.com/ruby/prism/commit/e752e251d2
2024-02-29 16:06:40 +00:00
Peter Zhu 8a918b456c Add gc_each_object for walking the heap 2024-02-29 10:57:24 -05:00
Kevin Newton cb784082bc [ruby/prism] Better hashing between positive/negative integers
https://github.com/ruby/prism/commit/68ddf08634
2024-02-29 14:53:42 +00:00
Peter Zhu 950c60623b Delete from finalizer_table before running finalizer
The finalizer could trigger a GC, which would cause FL_FINALIZE to be
out of sync with the finalizer table.
2024-02-29 09:38:13 -05:00
Peter Zhu d5bca0668c Unset FL_FINALIZE before running the finalizer
The finalizer could trigger a GC, so FL_FINALIZE could get out of sync
with the finalizer table.
2024-02-29 09:37:38 -05:00
Soutaro Matsumoto 1a6a7c699c
Update RBS (#10121)
Use an unreleased version of RBS to see if the new commit fixes the `EBADF` error.
2024-02-29 21:32:16 +09:00
Yuta Saito 3f633e57ac [wasm-pic] Remove --pass-arg=asyncify-ignore-imports from POSTLINK
Before PIC era, we could assume that the stack is not unwound by
imported functions since all imported functions are WASI syscalls and
they don't use Asyncify at all. However, PIC binary can import functions
from other modules and we cannot guarantee that they won't unwind
the stack.
2024-02-29 19:57:49 +09:00
Nobuyoshi Nakada 114c0b71be
Inform failures in parallel tests before retrying
Displays for each failure which test it actually occurred in.  The
output destination follows the --{stdout,stderr}-on-failure option.
2024-02-29 18:05:00 +09:00