Commit graph

12164 commits

Author SHA1 Message Date
Samuel Giddins
cdcc760dc0 [rubygems/rubygems] Broader version compatibility in marshal tests
6ec518c563
2023-09-20 02:02:59 +00:00
Samuel Giddins
c80a4d453a [rubygems/rubygems] Fix UTC time loading
2a4d0a44b0
2023-09-20 02:02:58 +00:00
Samuel Giddins
d182d83ce9 [rubygems/rubygems] Add a Marshal.load replacement that walks an AST to safely load permitted classes/symbols
7e4478fe73
2023-09-20 02:02:58 +00:00
Benoit Daloze
7fc73ab5f6 [ruby/yarp] Only keep semantic fields in Java, i.e. skip location fields
* Add $YARP_SERIALIZE_ONLY_SEMANTICS_FIELDS to control where to serialize location fields at templating time,
  this way there is no overhead for either case and nothing to check at runtime.
* Add a byte in the header to indicate whether location fields are included as expected.
* Fixes https://github.com/ruby/yarp/issues/807
* Simplify the build-java CI job now that the FFI backend is available so JRuby can serialize.
* Support keeping some location fields which are still needed until there is a replacement

fc5cf2df12
2023-09-19 17:20:01 +00:00
Kevin Newton
4da53fd3a7 [ruby/yarp] Better Node#pretty_print
Respect the current indentation

068333ef49
2023-09-19 16:57:46 +00:00
Samuel Giddins
4023637d20 [rubygems/rubygems] Reduce allocations for stub specifications
This helps with memory usage during application boot time

```
==> memprof.after.txt <==
Total allocated: 1.43 MB (18852 objects)
Total retained:  421.12 kB (4352 objects)

==> memprof.before.txt <==
Total allocated: 2.43 MB (28355 objects)
Total retained:  469.69 kB (5425 objects)
```

See https://bugs.ruby-lang.org/issues/19890 about the readline
allocations

d7eb66eee3
2023-09-19 07:25:51 +00:00
Samuel Giddins
cea7e6ecca [rubygems/rubygems] Lazily construct fetcher debug messages
Avoids constructing several strings

8a322dbe11
2023-09-19 07:14:53 +00:00
nick evans
dfb2b4cbc9 [ruby/securerandom] Add support for UUID version 7
Although the specification for UUIDv7 is still in draft, the UUIDv7
algorithm has been relatively stable as it progresses to completion.

Version 7 UUIDs can be very useful, because they are lexographically
sortable, which can improve e.g: database index locality.  See section
6.10 of the draft specification for further explanation:

  https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/

The specification allows up to 12 bits of extra timestamp precision, to
make UUID generation closer to monotonically increasing.  This provides
between 1ms and ~240ns of timestamp precision.  At the cost of some code
complexity and a small performance penalty, a kwarg may specify any
arbitrary precision between 0 and 12 extra bits.  Any stronger
guarantees of monotonicity have considerably larger tradeoffs, so
nothing more is implemented.  This limitation is documented.

Ruby issue: https://bugs.ruby-lang.org/issues/19735

34ed1a2ec3
2023-09-19 01:55:27 +00:00
0x1eef
e77c766b7a [ruby/net-http] No longer neccessary to call String#freeze on string literals.
See #144

5a986c13d3
2023-09-19 01:32:18 +00:00
Yoshiki Takagi
465c222ef1 [rubygems/rubygems] Bump actions/checkout to v4 in bundler gem template
5ed4c600da
2023-09-19 01:06:35 +00:00
Jeremy Evans
230834d9bb [ruby/base64] Bump required_ruby_version to 2.4.0
The gem depends on String#unpack1, which was introduced in Ruby 2.4.

9f0e4ba155
2023-09-19 01:04:54 +00:00
Kevin Newton
1636f6abd6 [ruby/yarp] Use compact_child_nodes where possible
c1911fa9b1
2023-09-18 17:48:52 +00:00
Chad Schroeder
a8afedce6d [ruby/irb] Handle Concurrent Sessions and Saving Readline::HISTORY
(https://github.com/ruby/irb/pull/651)

* handle concurrent sessions and saving Readline::HISTORY, fixes https://github.com/ruby/irb/pull/510

* separate tests

* don't mutate the HISTORY object on the class

* avoid repeated .to_i calls

* remove intermediary history array

* work with array, fix test comment

---------

1681ada328

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-09-16 12:48:32 +00:00
Kevin Newton
7f96c9be9e [ruby/yarp] Bump to version 0.12.0
c71137377f
2023-09-16 00:32:52 +00:00
Martin Emde
010017d86d [rubygems/rubygems] Reduce array allocations and concatenations in Index
Remove the default nested hash in Index entirely
Index#search_all now yields or returns enum since that's what caller
needs.

c45ea3bbe2
2023-09-15 22:01:11 +00:00
Samuel Giddins
2cf5fe58fb [rubygems/rubygems] Avoid allocating empty hashes in Index
Since the hashes have a default proc that returns a (new) empty hash, we
can avoid allocating those empty hashes when we are only doing lookups.

Test from running `bundle update --bundler` against a rails app I have
lying around:

```
==> memprof.after.txt <==
Total allocated: 9.71 MB (68282 objects)
Total retained:  4.87 MB (33791 objects)

==> memprof.before.txt <==
Total allocated: 10.83 MB (100596 objects)
Total retained:  5.02 MB (34721 objects)
```

8f7c9cb23e
2023-09-15 22:01:10 +00:00
Tim Morgan
4e8869c663 [ruby/yarp] Use templated constants for Regexp options
38e1769c2e
2023-09-15 21:47:28 +00:00
Tim Morgan
101ac364a5 [ruby/yarp] Return Regexp options that match MRI for e, u, s, and n
17dbf4ec46
2023-09-15 21:47:27 +00:00
Samuel Giddins
c423d6e0e4 [rubygems/rubygems] Stop allocating the same settings keys repeatedly
Running `bundle update --bundler` on a rails app locally:

```
==> memprof.after.txt <==
Total allocated: 301.90 kB (3794 objects)
Total retained:  73.24 kB (698 objects)

==> memprof.before.txt <==
Total allocated: 14.47 MB (196378 objects)
Total retained:  25.93 kB (202 objects)
```

So for a slight increase in retained memory (all keys are now retained),
we go from about 200k allocations in the settings file to under 4k

e64debb6ae
2023-09-15 17:54:01 +00:00
Kevin Newton
6031ab18c7 [ruby/yarp] Support parsing numbered parameters
ffc8f35e56
2023-09-15 15:14:34 +00:00
Martin Emde
66ffa15ce0 [rubygems/rubygems] Gemfile ruby file: covers more version formats
Increase test coverage and be explicit about what is and is not supported.

a096397a00
2023-09-14 19:43:21 +00:00
Martin Emde
d43765c3a9 [rubygems/rubygems] Unify LockfileParser loading of SPECS section
Ensure unrecognized SPECS types are ignored

5b33e91075
2023-09-12 19:42:46 +00:00
Kevin Newton
14a83e0879 [ruby/yarp] Update pretty_print to use inspect
c2b9b780c7
2023-09-11 21:32:15 +00:00
negi0109
203fdd738b [rubygems/rubygems] Fixed include realpath in error statement
ac3b85bd5e
2023-09-11 21:06:22 +00:00
negi0109
8bb61077ad [rubygems/rubygems] Fixed false positive SymlinkError in symbolic link directory
58173ff2ea
2023-09-11 21:06:21 +00:00
Kevin Newton
719f834466 [ruby/yarp] Mark flags as private
The flags integer is an implementation detail. We want people to
use the query methods to access the individual fields so we are
freed from having to maintain a specific order. As such, this
commit changes the Ruby API to mark all flags fields as private
attr_readers.

The only one that has a clear use case is returning the set of
options given to regular expressions, to mirror the Regexp#options
API. So, to support this use case, this commit introduces
RegularExpressionNode#options and InterpolatedRegularExpressionNode#options.
These APIs provide back the same integer so that they can be used
interchangeably.

4e6d5dd99f
2023-09-11 16:18:32 +00:00
Kevin Newton
f4443f3b1c [ruby/yarp] Increment version
2b41ceb754
2023-09-08 19:50:47 +00:00
Kevin Newton
c0f162caab [ruby/yarp] Template out a comment_targets method
a94af7c4c8
2023-09-08 19:38:17 +00:00
Kevin Newton
5d73c0f3df [ruby/yarp] Move parse result mutations into their own files
3be8272fa2
2023-09-08 19:38:17 +00:00
Vinicius Stock
6050b5a4e8 [ruby/yarp] Add ParseResult#attach_comments! to tie comments to their locations
ddc699156f

Co-authored-by: Kevin Newton <kddnewton@users.noreply.github.com>
2023-09-08 18:10:26 +00:00
Kevin Newton
9343ef2504 [ruby/yarp] Constants on rest parameter nodes
a6fdb8aae9
2023-09-07 12:42:02 +00:00
Kevin Newton
9e21b33ece [ruby/yarp] Constants on keyword parameters
d2d4f25a23
2023-09-07 12:42:00 +00:00
Martin Emde
89cb95679d [rubygems/rubygems] Reduce excess index creation and merging
When @allow_cached is true, @allow_local is always true,
therefore, the #installed_specs will always be merged after #cached_specs
is called. This makes starting with installed_specs.dup redundant.

When #cached_specs is called because @allow_remote is true and
@allow_cached is false, then installed_specs will be added after
cached_specs based on @allow_local.

We never need to add installed_specs here, so don't.

49b38f9750
2023-09-07 00:33:29 +00:00
Martin Emde
86b93f7481 [rubygems/rubygems] Improve efficiency of Index#use and #search_all
Rename Index#use(override = true) to #merge!

Rename Index @all_specs to @duplicates, it is not actually all specs.
@duplicates only holds specs that would have been overridden during a call to
Index#use or Index#merge!

Reduced dupes in @duplicates by not double adding the new spec to the
index and the @duplicates during #merge!

Reduce Array creation by using specialized methods when the one result
or no results are needed from the search.

47e91125db
2023-09-07 00:33:28 +00:00
Martin Emde
af1bedbbd9 [rubygems/rubygems] Source::Rubygems#fetch_names is only called with override = false
790202691d
2023-09-07 00:33:28 +00:00
Andy Waite
fdf7aad902 [ruby/yarp] Fix Location#end_column
00e4711026
2023-09-06 18:37:41 +00:00
Kevin Newton
dae6a0a295 [ruby/yarp] Introduce YARP::Pattern
2a12e9637b
2023-09-06 14:19:58 +00:00
Kevin Newton
4c9a036606 [ruby/yarp] Add constants and constants
d7eaa89bc3
2023-09-06 13:00:23 +00:00
Stan Lo
d83b5ea09d [ruby/irb] Bump version to 1.8.1
(https://github.com/ruby/irb/pull/706)

c7c838a4bf
2023-09-05 13:42:21 +00:00
Nobuyoshi Nakada
dab6d55db1 [ruby/rdoc] Remove code for versions older than Ruby 2.6
0d10f460eb
2023-09-05 01:14:52 +00:00
Nobuyoshi Nakada
736092ec11 [ruby/rdoc] Remove code for versions older than Ruby 2.3
a61b777df0
2023-09-05 01:14:51 +00:00
Jeremy Evans
3f6c92e9d5 [ruby/rdoc] Omit descriptions and parameter lists for methods defined in C not mentioned in call-seq
This allows RDoc to better generate documentation for methods
following the Ruby core documentation guide (which omits aliases
in call-seq in most cases).  This makes documentation for methods
defined in C more similar to methods defined in Ruby.  For methods
defined in Ruby, the method description of the aliased method is
already not used (you have to explicitly document the alias to
use it).

Internally, this adds AnyMethod#has_call_seq? and #skip_description?,
and updates Darkfish to:

* only show the method name if there is a call-seq for the method,
  but the call-seq omits the method
* to omit the method description if the method is an alias or has
  aliases and has a call-seq that does not include the method

See discussion in https://github.com/ruby/ruby/pull/7316 for
details.

e3688de49b
2023-09-05 00:45:42 +00:00
theo-squadracer
a14ba622da [ruby/rdoc] handle symbols declared with %s
ed91c4b784
2023-09-05 00:37:30 +00:00
Kevin Newton
e8ef5b1281 [ruby/yarp] Provide a better inspect
ef14ae66e4
2023-09-01 16:18:11 -07:00
Kevin Newton
c666077182 [ruby/yarp] Add global variables to the constant pool
b48067b067
2023-09-01 22:52:14 +00:00
Kevin Newton
1c622a6b58 [ruby/yarp] Bump to v0.10.0
b6164a76d9
2023-09-01 20:56:15 +00:00
Benoit Daloze
4172036bc6 [ruby/yarp] Do not desugar Foo::Bar {||,&&,+}= baz as it is incorrect without a temporary variable
* See https://github.com/ruby/yarp/pull/1329#discussion_r1310775433 for details.

f0fdcba0c3
2023-09-01 13:18:29 +00:00
Benoit Daloze
7fb56df726 [ruby/yarp] Fix comments for methods using desugar_or_write_defined_node
a39147736e
2023-09-01 13:18:29 +00:00
Stan Lo
3678734fac [ruby/irb] Drop rdoc's version requirement
(https://github.com/ruby/irb/pull/704)

1. The newer versions of rdoc requires pysch 4.0+, which could break apps
   using Ruby 3.0 or 2.7. #703 has more detailed explanation on this.
2. We actually don't use any version-specific rdoc APIs. So having a version
    requirement is not necessary atm.

3e6ba78c42
2023-08-31 15:44:17 +00:00
Stan Lo
8804a70387 [ruby/irb] Require Reline 0.3.8+
(https://github.com/ruby/irb/pull/702)

Reline 0.3.8 reduces the chance of having a deadlock with the debugger
while using the new `irb:rdbg` integration.

9b8c56b7d4
2023-08-31 14:08:08 +00:00