Commit graph

77079 commits

Author SHA1 Message Date
Hiroshi SHIBATA
633fde4152 Try to use https://github.com/ruby/rbs/pull/1207 2023-01-12 19:33:23 +09:00
Stan Lo
019c65828b [ruby/irb] Remove redundant argument defaults from some RubyLex
methods
(https://github.com/ruby/irb/pull/502)

* Remove unnecessary parameter defaults

These methods are always called with tokens specified. So their default
`@tokens` value is never used and is misleading.

* Remove unnecessary context default

* Require tokens for `RubyLex#check_state`
2023-01-12 10:30:17 +00:00
elfham
aa66595876 [ruby/reline] Update to Unicode 15.0.0
(https://github.com/ruby/reline/pull/437)

* Update to Unicode 14.0.0

* Update to Unicode 15.0.0
2023-01-12 09:40:34 +00:00
Takashi Kokubun
d4a3882c1c
Assert possible hash functions in RHASH_ST_TABLE (#7107)
Because of the function pointer, it's hard to figure out what hash
functions could be used in Hash objects when st_lookup is used.

Having this assertion makes it easier to understand what
hash_stlike_lookup could possibly do. (AR uses only rb_any_hash)

For example, this clarifies that hash_stlike_lookup never calls a #hash
method when a key is T_STRING or T_SYMBOL.
2023-01-11 23:14:58 -08:00
Jean Boussier
a8537eae2a [ruby/mutex_m] Avoid anonymous eval
It makes it hard to locate code when profiling etc.

8760ab19ec
2023-01-12 05:41:59 +00:00
Hiroshi SHIBATA
0e21c9f57e [ruby/mutex_m] Drop to support Ruby 2.4
9245b9a63a
2023-01-12 05:38:31 +00:00
Hiroshi SHIBATA
fe11bee507
Suppressing installation messages with test-bundler
Ignoring the following messages:

    ```
    (snip)
            -e 'load "spec/bundler/support/bundle.rb"' -- install --gemfile=tool/bundler/dev_gems.rb
    Using rake 13.0.6
    Using bundler 2.5.0.dev
    Using diff-lcs 1.5.0
    Using parallel 1.22.1
    Using parallel_tests 2.32.0
    Using power_assert 2.0.2
    Using rb_sys 0.9.52
    Using rspec-support 3.12.0
    Using rspec-core 3.12.0
    Using rspec-expectations 3.12.0
    Using rspec-mocks 3.12.1
    Using test-unit 3.5.5
    Using uri 0.12.0
    Using webrick 1.7.0
    Bundle complete! 11 Gemfile dependencies, 14 gems now installed.
    Gems in the groups 'lint' and 'doc' were not installed.
    Use `bundle info [gemname]` to see where a bundled gem is installed.
    ```
2023-01-12 10:46:54 +09:00
卜部昌平
617b3f697d enhance build matrix 2023-01-12 10:15:58 +09:00
Nobuyoshi Nakada
cc15963aa3
Strip trailing spaces [ci skip] 2023-01-12 09:29:56 +09:00
tomoya ishida
0abb4b6348 [ruby/reline] Pass unmodifined lines(that does not include escape
sequence) to check_multiline_prompt
(https://github.com/ruby/reline/pull/458)

* pass unmodified lines to check_multiline_prompt

* Add test to check that output modified by output_modifier_proc is not passed to prompt_proc
2023-01-12 00:14:53 +00:00
Hiroshi SHIBATA
048751dd73
Generate parser-text.rb with bcdc058e50 2023-01-12 07:54:39 +09:00
Jean Boussier
bcdc058e50 [ruby/racc] Get rid of anonymous eval calls
Things declared in anonymous eval are always annoying to locate.
(profilers, etc)

f304205256
2023-01-12 07:52:29 +09:00
Masataka Pocke Kuwabara
11e15b4d48 [ruby/racc] Make racc Ractor compatible
1948de9d1d
2023-01-12 07:52:25 +09:00
Hiroshi SHIBATA
7e283c585e [ruby/irb] Formatting to header styles
cef125850d
2023-01-11 22:29:10 +00:00
Hiroshi SHIBATA
128398e7cd [ruby/irb] After Ruby 2.0, coding is always utf-8
7a94bc4135
2023-01-11 22:29:10 +00:00
Hiroshi SHIBATA
c7bb8d67b7 [ruby/irb] Removed Release Version and Revisions for old VCS software
07fae94862
2023-01-11 22:29:09 +00:00
Stan Lo
c693dfd7ef [ruby/irb] Drop unused arguments in RubyLex
(https://github.com/ruby/irb/pull/504)

* Simplify `RubyLex#set_prompt`

It's optional argument is never used by any caller.

* Remove the optional `p` argument from `RubyLex#set_input`

The argument is only used in a test case, which can be easily replaced by
a block argument.
2023-01-11 21:26:18 +00:00
Takashi Kokubun
3642006872
YJIT: Add a few asm comments (#7105)
* YJIT: Add a few asm comments

* YJIT: Clarify exiting insns

* YJIT: Fix cargo test
2023-01-11 11:12:15 -08:00
Jemma Issroff
ad5ab0c3ea Remove unnecessary set of INVALID_SHAPE_ID in rb_callcache
We don't use this value, so there's no need to set it.
2023-01-11 10:01:11 -08:00
Peter Zhu
abff5f6203 Move classpath to rb_classext_t
This commit moves the classpath (and tmp_classpath) from instance
variables to the rb_classext_t. This improves performance as we no
longer need to set an instance variable when assigning a classpath to
a class.

I benchmarked with the following script:

```ruby
name = :MyClass

puts(Benchmark.measure do
  10_000_000.times do |i|
    Object.const_set(name, Class.new)
    Object.send(:remove_const, name)
  end
end)
```

Before this patch:

```
  5.440119   0.025264   5.465383 (  5.467105)
```

After this patch:

```
  4.889646   0.028325   4.917971 (  4.942678)
```
2023-01-11 11:06:58 -05:00
Peter Zhu
d86833e717 Make variation_count an unsigned char
Since SHAPE_MAX_VARIATIONS is 8, it can easily fit inside an unsigned
char.
2023-01-11 11:06:58 -05:00
Nobuyoshi Nakada
a468213917 [DOC] Mention the conditional regexp 2023-01-11 23:25:28 +09:00
Peter Zhu
ac8cf010bc Remove check for RCLASS_EXT in variable.c
A class/module should always have a RCLASS_EXT, so we shouldn't need to
check that it exists.
2023-01-11 09:16:34 -05:00
Benoit Daloze
327cf5ec40 Skip rbs Encoding#replicate test 2023-01-11 13:41:41 +01:00
Benoit Daloze
6abe20e87b Remove Encoding#replicate 2023-01-11 13:41:41 +01:00
Phillip Hellewell
d831b1d5ce [ruby/reline] Reset IOGate in test_reset
331c1094ef
2023-01-11 11:38:51 +00:00
Phillip Hellewell
4222083cbd [ruby/reline] Change IOGate back to GeneralIO
Staying with ANSI can cause side effects with other tests.

ba36067802
2023-01-11 11:38:50 +00:00
Hiroshi SHIBATA
b311c35bdb Suppressing pending messages with RSpec 2023-01-11 20:00:21 +09:00
Jean Boussier
3161fd4372 [ruby/psych] Get rid of anonymous eval calls
Things declared in anonymous eval are always annoying to locate.

38871ad4e5
2023-01-11 10:08:13 +00:00
Jean Boussier
e85ef212de [ruby/set] Avoid the block or return pattern to save Proc allocations
Using the block param in a boolean context like this cause it to be
allocated.

Using it with an `if` or `unless` was optimized in 3.2
(https://github.com/ruby/ruby/pull/6286) but using it with `or`
or `and` wasn't.

```ruby
def foo(&block)
  block or return 1
end

puts RubyVM::InstructionSequence.of(method(:foo)).disasm
== disasm: #<ISeq:foo@(irb):11 (11,0)-(13,3)> (catch: false)
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: 0, kw: -1@-1, kwrest: -1])
[ 1] block@0<Block>
0000 getblockparam                          block@0, 0                (  12)[LiCa]
0003 dup
0004 branchif                               10
0006 pop
0007 putobject_INT2FIX_1_
0008 leave                                  [Re]
0009 putnil
0010 leave
```

versus

```
def foo(&block)
  return 1 if block
end

puts RubyVM::InstructionSequence.of(method(:foo)).disasm
== disasm: #<ISeq:foo@(irb):15 (15,0)-(17,3)> (catch: false)
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: 0, kw: -1@-1, kwrest: -1])
[ 1] block@0<Block>
0000 getblockparamproxy                     block@0, 0                (  16)[LiCa]
0003 branchunless                           7
0005 putobject_INT2FIX_1_
0006 leave                                                            (  17)[Re]
0007 putnil                                                           (  16)
0008 leave
```

e89da977d4
2023-01-11 09:26:08 +00:00
Koichi Sasada
8c2b6926d2 Skip unfixed assertion about objspace/dump_all
```
{"address":"0x7f8c03e9fcf0", "type":"STRING", "shape_id":10, "slot_size":40, "class":"0x7f8c00dbed98", "frozen":true, "embedded":true, "fstring":true, "bytesize":5, "value":"TEST2", "encoding":"US-ASCII", "coderange":"7bit", "memsize":40, "flags":{"wb_protected":true}}
{"address":"0x7f8c03e9ffc0", "type":"STRING", "shape_id":0, "slot_size":40, "class":"0x7f8c00dbed98", "embedded":true, "bytesize":5, "value":"TEST2", "encoding":"US-ASCII", "coderange":"7bit", "memsize":40, "flags":{"wb_protected":true}}
{"address":"0x7f8c03e487c0", "type":"STRING", "shape_id":0, "slot_size":40, "class":"0x7f8c00dbed98", "embedded":true, "bytesize":5, "value":"TEST2", "encoding":"UTF-8", "coderange":"unknown", "file":"-", "line":4, "method":"dump_my_heap_please", "generation":1, "memsize":40, "flags":{"wb_protected":true}}
  1) Failure:
TestObjSpace#test_dump_all [/tmp/ruby/src/trunk-gc-asserts/test/objspace/test_objspace.rb:622]:
number of strings.
<2> expected but was
<3>.
```

This failure only occurred on a ruby built with `DEFS=\"-DRGENGC_CHECK_MODE=2\""`
and only on a specific machine (Docker container) and difficult to reproduce,
so skip this failure to check other failures.
2023-01-11 18:09:48 +09:00
Kazuhiro NISHIYAMA
2038c5c45a
Remove about ext/psych/yaml which is no longer bundled [ci skip] 2023-01-11 18:05:15 +09:00
Aaron Patterson
5bf7218b01
Differentiate T_ARRAY and array subclasses (#7091)
* Differentiate T_ARRAY and array subclasses

This commit teaches the YJIT context the difference between Arrays
(objects with type T_ARRAY and class rb_cArray) vs Array subclasses
(objects with type T_ARRAY but _not_ class rb_cArray).  It uses this
information to reduce the number of guards emitted when using
`jit_guard_known_klass` with rb_cArray, notably opt_aref

* Update yjit/src/core.rs

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2023-01-10 13:54:07 -05:00
Alan Wu
aeddc19340
YJIT: Save PC and SP before calling leaf builtins (#7090)
Previously, we did not update `cfp->sp` before calling the C function of
ISEQs marked with `Primitive.attr! "inline"` (leaf builtins). This
caused the GC to miss temporary values on the stack in case the function
allocates and triggers a GC run. Right now, there is only a few leaf
builtins in numeric.rb on Integer methods such as `Integer#~`. Since
these methods only allocate when operating on big numbers, we missed
this issue.

Fix by saving PC and SP before calling the functions -- our usual
protocol for calling C functions that may allocate on the GC heap.

[Bug #19316]
2023-01-10 11:11:10 -05:00
Takashi Kokubun
6a585dbd5a
YJIT: Fix a compilation warning with release build (#7092)
warning: unused variable: `start_addr`
   --> ../yjit/src/asm/mod.rs:359:39
    |
359 |     pub fn remove_comments(&mut self, start_addr: CodePtr, end_addr: CodePtr) {
    |                                       ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_start_addr`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `end_addr`
   --> ../yjit/src/asm/mod.rs:359:60
    |
359 |     pub fn remove_comments(&mut self, start_addr: CodePtr, end_addr: CodePtr) {
    |
2023-01-10 11:00:25 -05:00
Nobuyoshi Nakada
be1db1ca5c
Just ignore empty lines in bundled_gems file [ci skip] 2023-01-10 23:31:04 +09:00
Peter Zhu
2861c8deaf Remove ARY_SET_SHARED
We don't need ARY_SET_SHARED since we already have rb_ary_set_shared.
2023-01-10 08:59:38 -05:00
Phillip Hellewell
97f8f2c470 [ruby/reline] Add key binding for Delete
603eacee22
2023-01-10 12:18:14 +00:00
Benoit Daloze
47ca75d38a Remove extra line which causes make test-bundled-gems-fetch to fail 2023-01-10 12:39:58 +01:00
Nobuyoshi Nakada
6053624a83
[DOC] Comments about fields in bundled_gems file 2023-01-10 17:34:56 +09:00
Hiroshi SHIBATA
a43f1d90c2 Merge RubyGems and Bundler master
from 0635c1423d
2023-01-10 15:53:07 +09:00
Hiroshi SHIBATA
89fb61f9a3
Update LEGAL sections for pub_grub 2023-01-10 13:39:31 +09:00
Hiroshi SHIBATA
f2fc7519b7
Removed vendored LICENSE file. 2023-01-10 13:13:06 +09:00
Hiroshi SHIBATA
900230837b
Fixed a typo 2023-01-10 13:07:36 +09:00
David Rodríguez
2e0159c5f2 [rubygems/rubygems] Fix resolver edge case
Let it deal with legacy gems with equivalent version and different
dependencies.

b430babe97
2023-01-10 12:58:28 +09:00
dependabot[bot]
97d52a8ea2 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.53 to 0.9.54.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.53...v0.9.54)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-10 02:20:54 +00:00
Takashi Kokubun
9792d9e40f Revert "Re-enable test_ractor for YJIT"
This reverts commit 650a20a3e1.

Now that 3.2.0 is released, let's disable flaky tests. Koichi said he'll
rework Ractor implementation for this, and it has not been done yet.
2023-01-09 17:43:47 -08:00
Takashi Kokubun
df76c54fc2 Allow overriding a gdb command on make gdb
With --enable-yjit, you see an annoying warning like this:

warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /home/k0kubun/src/github.com/ruby/ruby/.ruby/miniruby.
Use `info auto-load python-scripts [REGEXP]' to list them.

Using `rust-gdb` instead fixes it. I use this like `make gdb GDB=rust-gdb`.
2023-01-09 16:45:50 -08:00
Peter Zhu
72eb33066f Fix off-by-one error in rb_vm_each_stack_value
Applying the following patch to test/erb/test_erb.rb and running that
file will cause Ruby to crash on my machine (macOS 13.1 on M1 Pro):

```
--- a/test/erb/test_erb.rb
+++ b/test/erb/test_erb.rb
@@ -7,6 +7,12 @@
 class TestERB < Test::Unit::TestCase
   class MyError < RuntimeError ; end

+  def setup
+    GC.auto_compact = true
+    GC.stress = true
+    GC.verify_compaction_references(expand_heap: true, toward: :empty)
+  end
+
```

It crashes with the following log:

```
/Users/peter/src/ruby/lib/erb/compiler.rb:276: [BUG] Segmentation fault at 0x00000001083a8690
...
-- C level backtrace information -------------------------------------------
...
/Users/peter/src/ruby/build/ruby(rb_vm_each_stack_value+0xa8) [0x104cc3a44] ../vm.c:2737
/Users/peter/src/ruby/build/ruby(rb_vm_each_stack_value+0xa8) [0x104cc3a44] ../vm.c:2737
/Users/peter/src/ruby/build/ruby(check_stack_for_moved+0x2c) [0x104b272a4] ../gc.c:5512
/Users/peter/src/ruby/build/ruby(gc_compact_finish) ../gc.c:5534
/Users/peter/src/ruby/build/ruby(gc_sweep_compact) ../gc.c:8653
/Users/peter/src/ruby/build/ruby(gc_sweep) ../gc.c:6196
/Users/peter/src/ruby/build/ruby(has_sweeping_pages+0x0) [0x104b19c54] ../gc.c:9568
/Users/peter/src/ruby/build/ruby(gc_rest) ../gc.c:9570
```

This crash happens because it's reading the VALUE at sp. But since
sp points to the top of the stack, it's reading the VALUE above the
top of the stack, which is causing this segfault.

Fixes [Bug #19320]
2023-01-09 16:00:42 -08:00
Takashi Kokubun
0247ccddab Fix a warning in .gdbinit
Warning: 'set logging on', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled on'.
2023-01-09 14:29:18 -08:00