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

77397 Коммитов

Автор SHA1 Сообщение Дата
Peter Zhu bffadcd6d4 Add guard to compaction test in WeakMap
Some platforms don't support compaction, so we should skip this test.
2023-04-06 13:35:25 -04:00
Peter Zhu bccec7fb46 Fix crash in rb_gc_register_address
[Bug #19584]

Some C extensions pass a pointer to a global variable to
rb_gc_register_address. However, if a GC is triggered inside of
rb_gc_register_address, then the object could get swept since it does
not exist on the stack.
2023-04-06 13:19:19 -04:00
Takashi Kokubun 89bdf6e94c
YJIT: Stack temp register allocation for arm64 (#7659)
* YJIT: Stack temp register allocation for arm64

* Update a comment

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>

* Update comments about assertion

* Update a comment

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>

---------

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2023-04-06 11:34:58 -04:00
Matt Valentine-House 2a34bcaa10 Update VPATH for socket, & dependencies
The socket extensions rubysocket.h pulls in the "private" include/gc.h,
which now depends on vm_core.h. vm_core.h pulls in id.h

when tool/update-deps generates the dependencies for the makefiles, it
generates the line for id.h to be based on VPATH, which is configured in
the extconf.rb for each of the extensions. By default VPATH does not
include the actual source directory of the current Ruby so the
dependency fails to resolve and linking fails.

We need to append the topdir and top_srcdir to VPATH to have the
dependancy picked up correctly (and I believe we need both of these to
cope with in-tree and out-of-tree builds).

I copied this from the approach taken in
https://github.com/ruby/ruby/blob/master/ext/objspace/extconf.rb#L3
2023-04-06 11:07:16 +01:00
Matt Valentine-House 026321c5b9 [Feature #19474] Refactor NEWOBJ macros
NEWOBJ_OF is now our canonical newobj macro. It takes an optional ec
2023-04-06 11:07:16 +01:00
Matt Valentine-House 879cda98a4 Remove dependancy of vm_core.h on shape.h
so that now shape can happily include gc.h
2023-04-06 11:07:16 +01:00
Matt Valentine-House d91a82850a Pull the shape tree out of the vm object 2023-04-06 11:07:16 +01:00
Matt Valentine-House b0297feb1f Remove newobj_of_cr
We can just make newobj_of take a ractor
2023-04-06 11:07:16 +01:00
Hiroshi SHIBATA f269fae07e
Revert "[ruby/syntax_suggest] Introduce binstubs to set RUBYOPT for development"
This reverts commit d2eef4b786.
2023-04-06 16:36:09 +09:00
Hiroshi SHIBATA 70371aa071
Revert accidentally commit of wrong file
Revert "[ruby/syntax_suggest] Remove unnecessary `--color` option"

  This reverts commit 588dd44d41.
2023-04-06 16:30:00 +09:00
git c78476cee8 Update default gems list at 6ca1f3eec4 [ci skip] 2023-04-06 07:18:54 +00:00
Hiroshi SHIBATA 6ca1f3eec4
Load only SyntaxSuggest::VERSION for version check 2023-04-06 16:15:41 +09:00
schneems 7ab640d9dd
v1.0.4 2023-04-06 15:49:26 +09:00
schneems 8d72d6159c
v1.0.3
Fix a CI error and add a test to ensure we're testing the current version:

```
Run bundle exec rake test
bundler: failed to load command: rake (/home/runner/work/syntax_suggest/syntax_suggest/vendor/bundle/ruby/3.2.0/bin/rake)
/opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:309:in `check_for_activated_spec!': You have already activated syntax_suggest 1.0.2, but your Gemfile requires syntax_suggest 1.0.3. Since syntax_suggest is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports syntax_suggest as a default gem. (Gem::LoadError)
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:25:in `block in setup'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/spec_set.rb:138:in `each'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/spec_set.rb:138:in `each'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:24:in `map'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:24:in `setup'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler.rb:151:in `setup'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `block in <top (required)>'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:136:in `with_level'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:88:in `silence'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `<top (required)>'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:56:in `require_relative'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:56:in `kernel_load'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:23:in `run'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli.rb:483:in `exec'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
```
2023-04-06 15:47:04 +09:00
schneems d2eef4b786 [ruby/syntax_suggest] Introduce binstubs to set RUBYOPT for development
Because `syntax_suggest` is a default gem you can get conflicts when working on this project with Ruby 3.2+. To fix conflicts you can disable loading `syntax_suggest` as a default gem by using then environment variable `RUBYOPT` with the value `--disable=syntax_suggest`. The `RUBYOPT` environment variable works the same as if we had entered those flags directly in the ruby cli (i.e. `ruby --disable=syntax_suggest` is the same as `RUBYOPT="--disable=syntax_suggest" ruby`). It's needed because we don't always directly execute Ruby and RUBYOPT will be picked up when other commands load ruby (`rspec`, `rake`, or `bundle` etc.).

There are some binstubs that already have this done for you. Instead of running `bundle exec rake` you can run `bin/rake`. Binstubs provided:

- `bin/rake`
- `bin/rspec`

https://github.com/ruby/syntax_suggest/commit/342093706d
2023-04-06 15:45:31 +09:00
Yusuke Endoh d511e6960f [ruby/syntax_suggest] The annotation must end with a new line
syntax_suggest did not work great when there is no new line at the end
of the input file.

Input:
```
def foo
end
end # No newline at end of file
```

Previous output:
```
$ ruby test.rb
test.rb: --> test.rb
Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
> 1  def foo
> 2  end
> 3  end # No newline at end of filetest.rb:3: syntax error, unexpected `end' (SyntaxError)
end # No newline at end of file
^~~
```

Note that "test.rb:3: ..." is appended to the last line of the
annotation.

This change makes sure that the annotation ends with a new line.

New output:
```
$ ruby test.rb
test.rb: --> test.rb
Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
> 1  def foo
> 2  end
> 3  end # No newline at end of file
test.rb:3: syntax error, unexpected `end' (SyntaxError)
end # No newline at end of file
^~~
```

https://github.com/ruby/syntax_suggest/commit/db4cf9147d
2023-04-06 15:45:30 +09:00
schneems 63ea6b0cf2 [ruby/syntax_suggest] Rollback comment indentation behavior
Originally I fixed https://github.com/ruby/syntax_suggest/pull/177 by making the process of comment removal indentation aware. The next commit is the more general fix and means we don't need to carry that additional logic/overhead.

Also: Update syntax via linter
2023-04-06 15:45:29 +09:00
schneems 2acbcec056 [ruby/syntax_suggest] Add comments and refactor AroundBlockScan methods
https://github.com/ruby/syntax_suggest/commit/cecd12292c
2023-04-06 15:45:29 +09:00
schneems 5487ee4fe8 [ruby/syntax_suggest] Fix sibling bug to #177
While #177 is reported as being caused by a comment, the underlying behavior is a problem due to the newline that we generated (from a comment). The prior commit fixed that problem by preserving whitespace before the comment. That guarantees that a block will form there from the frontier before it will be expanded there via a "neighbors" method. Since empty lines are valid ruby code, it will be hidden and be safe.

## Problem setup

This failure mode is not fixed by the prior commit, because the indentation is 0. To provide good results, we must make the algorithm less greedy. One heuristic/signal to follow is developer added newlines. If a developer puts a newline between code, it's more likely they're unrelated. For example:

```
port = rand(1000...9999)
stub_request(:any, "localhost:#{port}")

query = Cutlass::FunctionQuery.new(
  port: port
).call

expect(WebMock).to have_requested(:post, "localhost:#{port}").
  with(body: "{}")
```

This code is split into three chunks by the developer. Each are likely (but not guaranteed) to be intended to stand on their own (in terms of syntax). This behavior is good for scanning neighbors (same indent or higher) within a method, but bad for parsing neighbors across methods.

## Problem

Code is expanded to capture all neighbors, and then it decreases indent level which allows it to capture surrounding scope (think moving from within the method to also capturing the `def/end` definition. Once the indentation level has been increased, we go back to scanning neighbors, but now neighbors also contain keywords.

For example:

```
  1 def bark
  2
  3 end
  4
  5 def sit
  6 end
```

In this case if lines 4, 5, and 6 are in a block when it tries to expand neighbors it will expand up. If it stops after line 2 or 3 it may cause problems since there's a valid kw/end pair, but the block will be checked without it.

TLDR; It's good to stop scanning code after hitting a newline when you're in a method...it causes a problem scanning code between methods when everything inside of one of the methods is an empty line.

In this case it grabs the end on line 3 and since the problem was an extra end, the program now compiles correctly. It incorrectly assumes that the block it captured was causing the problem.

## Extra bit of context

One other technical detail is that after we've decided to stop scanning code for a new neighbor block expansion, we look around the block and grab any empty newlines. Basically adding empty newlines before of after a code block do not affect the parsing of that block.

## The fix

Since we know that this problem only happens when there's a newline inside of a method and we know this particular failure mode is due to having an invalid block (capturing an extra end, but not it's keyword) we have all the metadata we need to detect this scenario and correct it.

We know that the next line above our block must be code or empty (since we grabbed extra newlines). Same for code below it. We can count all the keywords and ends in the block. If they are balanced, it's likely (but not guaranteed) we formed the block correctly. If they're imbalanced, look above or below (depending on the nature of the imbalance), check to see if adding that line would balance the count.

This concept of balance and "leaning" comes from work in https://github.com/ruby/syntax_suggest/pull/152 and has proven useful, but not been formally introduced into the main branch.

## Outcome

Adding this extra check introduced no regressions and fixed the test case. It might be possible there's a mirror or similar problem that we're not handling. That will come out in time. It might also be possible that this causes a worse case in some code not under test. That too would come out in time.

One other possible concern to adding logic in this area (which is a hot codepath), is performance. This extra count check will be performed for every block. In general the two most helpful performance strategies I've found are reducing total number of blocks (therefore reducing overall N internal iterations) and making better matches (the parser to determine if a close block is valid or not is a major bottleneck. If we can split valid code into valid blocks, then it's only evaluated by the parser once, where as invalid code must be continuously re-checked by the parser until it becomes valid, or is determined to be the cause of the core problem.

This extra logic should very rarely result in a change, but when it does it should tend to produce slightly larger blocks (by one line) and more accurate blocks.

Informally it seems to have no impact on performance:

``
This branch:
DEBUG_DISPLAY=1 bundle exec rspec spec/ --format=failures  3.01s user 1.62s system 113% cpu 4.076 total
```

```
On main:
DEBUG_DISPLAY=1 bundle exec rspec spec/ --format=failures  3.02s user 1.64s system 113% cpu 4.098 total
```

https://github.com/ruby/syntax_suggest/commit/13739c6946
2023-04-06 15:45:28 +09:00
schneems e5236471c3 [ruby/syntax_suggest] Preserve whitespace in front of comments
When removing comments I previously replaced them with a newline. This loses some context and may affect the order of the indent search which in turn affects the final result. By preserving whitespace in front of the comment, we preserve the "natural" indentation order of the line while also allowing the parser/lexer to see and join naturally consecutive (method chain) lines.

close https://github.com/ruby/syntax_suggest/pull/177
2023-04-06 15:45:28 +09:00
schneems 33cfd262fc [ruby/syntax_suggest] Handle alias already exists when debugging
When `tmp/alias` already exists, I'm now getting phantom folders in the directory pointing at older aliases which is distracting/confusing. By checking and removing that alias before symlinking we can prevent this strange behavior (possibly caused by newer Mac OS?).
2023-04-06 15:45:27 +09:00
Nobuyoshi Nakada 588dd44d41 [ruby/syntax_suggest] Remove unnecessary `--color` option
It is enabled automatically if possible.  Forcing this option makes
https://github.com/rspec/rspec-core/pull/3017 useless.

https://github.com/ruby/syntax_suggest/commit/8e7141b472
2023-04-06 15:45:27 +09:00
Marc-Andre Lafortune 061f5f4374 Add missing test for Data.initialize 2023-04-06 09:24:38 +03:00
Vít Ondruch 69460791cc
[rubygems/rubygems] Improve comment explaining the neccessity of `write_default_spec` method.
The intention is not obvious from the commit log and it might avoid
temptation to remove the method without further consideration.

https://github.com/rubygems/rubygems/commit/8e17c50f64
2023-04-06 13:07:16 +09:00
David Rodríguez f3d69bed62
[rubygems/rubygems] Fix resolver hangs when dealing with an incomplete lockfile
While working on locking multiple platforms by default, I got an
infinite resolution loop in one of our resolver specs.

The culprit ended up being that when dealing with lockfile specs with
incomplete dependencies (spec appears in lockfile, but its dependencies
don't), those specs were not being properly expired and that tripped up
resolution.

The issue for some reason only manifests when dealing with multiple
lockfile platforms, that's why it only manifested when working on
locking multiple platforms by default.

https://github.com/rubygems/rubygems/commit/4ca72913bb
2023-04-06 13:07:16 +09:00
David Rodríguez c257380965
Revert "Refactor incomplete specs handling"
This reverts commit 69580f8b72f41c58cae57d1ada4db909922b3891.
2023-04-06 13:07:16 +09:00
David Rodríguez 192a3a6bfb
[rubygems/rubygems] Revert "Reuse `SpecSet#materialize` logic"
This reverts commit https://github.com/rubygems/rubygems/commit/a20585b4512d.

https://github.com/rubygems/rubygems/commit/aa9102659e
2023-04-06 13:07:16 +09:00
Vít Ondruch b5f2432917
[rubygems/rubygems] Use TestCase#util_spec instead of custom code.
https://github.com/rubygems/rubygems/commit/74d485ff1e
2023-04-06 13:07:16 +09:00
dependabot[bot] 5d718f109d Bump github/codeql-action from 2.2.9 to 2.2.10
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.2.9 to 2.2.10.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](04df1262e6...8c8d71dde4)

---
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>
2023-04-06 12:43:19 +09:00
Adam Hess 7b27ad9ad3
Add BIN as an entry in the glossary (#7667)
I initially thought this macro is referencing binary, not basic instruction name
2023-04-05 16:11:04 -07:00
Stan Lo 2f8e5c80e6 [ruby/irb] Drop Ruby 2.6 support
(https://github.com/ruby/irb/pull/555)

* Remove all Ruby 2.6 support

* Drop Ruby 2.6 specific testing conditions

* Only run Ruby 2.7+ on CI

* Bump Ruby requirement to 2.7+

https://github.com/ruby/irb/commit/3f714b616c
2023-04-05 21:40:40 +00:00
Takashi Kokubun 1587494b0b
YJIT: Add codegen for Integer methods (#7665)
* YJIT: Add codegen for Integer methods

* YJIT: Update dependencies

* YJIT: Fix Integer#[] for argc=2
2023-04-05 13:19:31 -07:00
Mike Dalessio 52e571fa72 Ensure ruby_xfree won't segfault if called after vm_destruct
[Bug #19580]

The real-world scenario motivating this change is libxml2's pthread
code which uses `pthread_key_create` to set up a destructor that is
called at thread exit to free thread-local storage.

There is a small window of time -- after ruby_vm_destruct but before
the process exits -- in which a pthread may exit and the destructor is
called, leading to a segfault.

Please note that this window of time may be relatively large if
`atexit` is being used.
2023-04-05 12:57:32 -04:00
Nobuyoshi Nakada 533423ebe4 core_assertions.rb: Prefer CPU time clocks
To prevent influence from other processes.
2023-04-06 00:19:03 +09:00
Nobuyoshi Nakada f9eb2515a3 core_assertions.rb: Extract common code block 2023-04-06 00:19:03 +09:00
Nobuyoshi Nakada f07c756494 core_assertions.rb: Tweak timeout limit
Increase the timeout limit when variance at rehearsal is small.
2023-04-06 00:19:03 +09:00
Daniel DeLorme 4b100f75d2 [DOC] Clarify behavior of abort() with no argument
Since Ruby 2.7 it prints the message and backtrace of $!

Fixes [Bug #19578]
2023-04-05 07:37:07 -07:00
Takashi Kokubun 615a1bc470
YJIT: Count the number of actually written bytes (#7658) 2023-04-05 10:32:04 -04:00
Alan Wu 3e1e09b2b7 YJIT: Smoke test on Rust 1.58.0
Since warnings might show up on older version but not newer ones.
2023-04-05 09:49:31 -04:00
Alan Wu 8f734cf93e YJIT: Eanble `unsafe_op_in_unsafe_fn` on crate::core
Encourages commenting about soundness of `unsafe` usages.
2023-04-05 09:49:31 -04:00
Alan Wu 929d55c3c7 Revert "YJIT: Suppress unnecessary `unsafe` block (GH-7634)"
This reverts commit 9e678cdbd0.

Without the `unsafe` annotations, the SAFETY comments make less sense.
I want to keep the SAFETY comments.
2023-04-05 09:49:31 -04:00
Hiroshi SHIBATA e003784fc8 [rubygems/rubygems] util/rubocop -A --only Style/RegexpLiteral
https://github.com/rubygems/rubygems/commit/9264d83421
2023-04-05 09:50:29 +00:00
Takashi Kokubun 65d27d3c0a RJIT: Skip a class guard if known to be T_STRING 2023-04-05 00:46:10 -07:00
Takashi Kokubun 9bef39de74 RJIT: Handle include_all argument of respond_to? 2023-04-05 00:38:38 -07:00
Takashi Kokubun 66fe64b269 RJIT: Remove unused variables 2023-04-04 23:55:19 -07:00
Takashi Kokubun 2ddf6079f1 RJIT: Always use guard_two_fixnums 2023-04-04 23:52:14 -07:00
Takashi Kokubun 4e9c3b4518 RJIT: Eliminate known-result guards for blockarg 2023-04-04 23:42:14 -07:00
Takashi Kokubun 4f77d1cdb8 RJIT: Eliminate known-result branches 2023-04-04 23:30:26 -07:00
Hiroshi SHIBATA 9a5d4cc80b [rubygems/rubygems] Removed unused Gem::Deprecate from Gem::TestCase
https://github.com/rubygems/rubygems/commit/d8a75a5f84
2023-04-05 05:49:26 +00:00
Hiroshi SHIBATA 8e37eb1d15 [rubygems/rubygems] Extract class method used by self.method
https://github.com/rubygems/rubygems/commit/d900453ca2
2023-04-05 05:49:26 +00:00