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

66504 Коммитов

Автор SHA1 Сообщение Дата
aycabta 1192393b3e Stop using global constant, RELINE_TEST_ENCODING 2021-06-21 22:12:14 +09:00
aycabta af19f9a6e9 Call Reline.test_reset in teardown definitely 2021-06-21 22:12:14 +09:00
aycabta 9498ea9385 Revert "Use Encoding.default_external for tests of Readline::HISTORY"
This reverts commit 089a26b0a6.
2021-06-21 22:12:14 +09:00
Yusuke Endoh ed8e265d4b Experimentally expose RubyVM::AST::Node#node_id
Now ISeq#to_a includes the node_id list for each bytecode instruction.
I want a way to retrieve the AST::Node instance corresponding to an
instruction for a research purpose including TypeProf-based LSP server.
2021-06-21 21:15:25 +09:00
aycabta 089a26b0a6 Use Encoding.default_external for tests of Readline::HISTORY 2021-06-21 19:31:14 +09:00
aycabta 30cc07fdc1 Check Ruby version to use Fiddle with variadic args in test-all 2021-06-21 18:44:10 +09:00
Ulysse Buonomo 5cc11845b2 [ruby/irb] Improve stackprof measure
Allow usage of more detailed args when setting stackprof callback.

Signed-off-by: Ulysse Buonomo <buonomo.ulysse@gmail.com>

https://github.com/ruby/irb/commit/c9d101f450
2021-06-21 18:03:49 +09:00
aycabta 90df426426 [ruby/reline] Version 0.2.6
https://github.com/ruby/reline/commit/5917e3a337
2021-06-21 17:58:49 +09:00
aycabta 00b027a69b [ruby/reline] Fix explamation of #read_io
https://github.com/ruby/reline/commit/301ed11bec
2021-06-21 17:58:49 +09:00
aycabta cf6f686d29 [ruby/reline] Remove an obsolete commented-out test
https://github.com/ruby/reline/commit/5354d02e03
2021-06-21 17:58:49 +09:00
aycabta 95a3cdade6 [ruby/reline] Remove FIXME comment in #render
https://github.com/ruby/reline/commit/acd8f8efbb
2021-06-21 17:58:49 +09:00
aycabta b06218ce6f [ruby/reline] Remove TODO comment in #render_partial
https://github.com/ruby/reline/commit/bb6ea232c2
2021-06-21 17:58:49 +09:00
aycabta cf186bfe14 [ruby/reline] Add yamatanooroti test about set and exchange mark
https://github.com/ruby/reline/commit/2e6fdca5c6
2021-06-21 17:58:49 +09:00
aycabta 8135f489be [ruby/reline] Add binding C-x C-x to em_exchange_mark on Windows
https://github.com/ruby/reline/commit/24a2489b62
2021-06-21 17:58:49 +09:00
aycabta 882c0d5015 [ruby/reline] Reset config for random test
https://github.com/ruby/reline/commit/c39615e1dd
2021-06-21 17:58:49 +09:00
aycabta fa5a258e93 [ruby/reline] Treat C-Space as M-Space on Windows
https://github.com/ruby/reline/commit/69beca2863
2021-06-21 17:58:49 +09:00
aycabta 582b5705ab [ruby/reline] Check existance of a constant, Fiddle::VERSION
https://github.com/ruby/reline/commit/4b74c3d83a
2021-06-21 17:58:48 +09:00
aycabta 18b79b4c49 [ruby/reline] Add Meta+arrow-keys in extended entries of terminfo
https://github.com/ruby/reline/commit/af6f6ed088
2021-06-21 17:58:48 +09:00
aycabta 60d1d6aa89 [ruby/reline] Terminfo.tigetstr should be able to receive tiparm in method chain
https://github.com/ruby/reline/commit/4a3e308163
2021-06-21 17:58:48 +09:00
aycabta 5e09da2f7a [ruby/reline] Terminfo.tigetstr and tiparm should return String object
https://github.com/ruby/reline/commit/1e287d10cc
2021-06-21 17:58:48 +09:00
aycabta 46c813969b [ruby/reline] Add terminfo support
https://github.com/ruby/reline/commit/74a7ffaa2f
2021-06-21 17:58:48 +09:00
aycabta 1b543dc226 [ruby/reline] Handle Errno::ENOTTY correctly
https://github.com/ruby/reline/commit/8daa392ba6
2021-06-21 17:58:48 +09:00
Jeremy Evans 242bad9a87 [ruby/reline] Fix Reline::Unicode.calculate_width when input is not a TTY
This fixes an error when output is redirected:

```
$ run_ruby -rreline -e '$stderr.puts Reline::Unicode.calculate_width("\u221a").inspect' </dev/null >/dev/null
/home/jeremy/tmp/ruby/lib/reline/ansi.rb:189:in `raw': Operation not supported by device (Errno::ENODEV)
```

The @@encoding -> defined?(@@encoding) changes is necessary because
without that part of the commit, the following error would be raised
by the above command:

```
/home/jeremy/tmp/reline/lib/reline/general_io.rb:10:in `encoding': uninitialized class variable @@encoding in Reline::GeneralIO (NameError)
```

Problem reported and initial patch for Windows provided by
Richard Sharman.

I tested this only on OpenBSD, but hopefully it works for other
operating systems.

Fixes [Bug #17493]

https://github.com/ruby/reline/commit/c001971bb3
2021-06-21 17:58:48 +09:00
aycabta 26f31f880c [ruby/reline] Treat return key correctly on Windows
To fix Reline::TestRendering#test_binding_for_vi_movement_mode.

https://github.com/ruby/reline/commit/0df3d2a1dc
2021-06-21 17:58:48 +09:00
aycabta 754bfc66f8 [ruby/reline] Add a test for pasting Cyrillic chars into command prompt on cp 850
This closes https://github.com/ruby/reline/issues/103.

https://github.com/ruby/reline/commit/213e0523d5
2021-06-21 17:58:48 +09:00
aycabta b0cc46b484 [ruby/reline] The config file must accept any character encoding
In Japan, so many programmers used EUC-JP to write text files that contain
Japanese. Many .inputrc files which contain EUC-JP are still being copied and
used. This commit supports the whole encoding of what user set including UTF-8.

ref. https://github.com/ruby/reline/pull/280

https://github.com/ruby/reline/commit/0b45022e16
2021-06-21 17:58:48 +09:00
aycabta c59bbd86a6 [ruby/reline] Use ReadConsoleInputW() instead of getwch()
This needs https://github.com/aycabta/yamatanooroti/pull/19, which is released
by yamatanooroti gem 0.0.7, to test with yamatanooroti.

https://github.com/ruby/reline/commit/06c1f45da1
2021-06-21 17:58:48 +09:00
Mark Delk a049dfd10a [ruby/reline] ensure reline's encoding is used when reading inputrc character values
This change ensures we use `Reline::IOGate`'s `encoding` when converting
characters from their integer values.

This fixes an issue that may occur if you have UTF characters in your
`.inputrc`, but your default encoding isn't set.

For example:

```
> 127864.ord.chr
RangeError: 127864 out of char range
from (pry):1:in `chr'
> Reline::IOGate.encoding
=> #<Encoding:UTF-8>
> 127864.ord.chr(Reline::IOGate.encoding)
=> "🍸"
```

https://github.com/ruby/reline/commit/cf372fc0fc
2021-06-21 17:58:48 +09:00
aycabta c2f30aaade [ruby/irb] Version 1.3.6
https://github.com/ruby/irb/commit/75aa8d159b
2021-06-21 17:35:46 +09:00
Nobuyoshi Nakada 60eee3c3cb
Fix syntax error in generated code 2021-06-21 11:20:31 +09:00
git 86b5c15e70 * 2021-06-21 [ci skip] 2021-06-21 11:08:33 +09:00
Nobuyoshi Nakada 28933c1071
Adjust indents 2021-06-21 11:08:02 +09:00
Jeremy Evans 72a4e1d3bb Tweak description of TracePoint :line event
"code" here is too ambiguous. TracePoint events only occur if there
is a new statement or expression on that line, not if the line
is a continuation of a previous statement or expression and there
is no new statement or expression on the line.

For example:

```
[
 foo,   # start of expression, line event
 bar    # continuation of expression, no line event
]

[
 foo,   # start of expression, line event
 (bar)  # new expression, line event
]

foo(    # start of expression, line event
  bar   # continuation of expression, no line event
)

foo(    # start of expression, line event
  (bar) # new expression, line event
)
```

Fixes [Bug #15634]
2021-06-19 13:55:28 +12:00
git 53a094ea45 * 2021-06-19 [ci skip] 2021-06-19 02:03:03 +09:00
eileencodes b91b3bc771 Add a cache for class variables
Redo of 34a2acdac788602c14bf05fb616215187badd504 and
931138b00696419945dc03e10f033b1f53cd50f3 which were reverted.

GitHub PR #4340.

This change implements a cache for class variables. Previously there was
no cache for cvars. Cvar access is slow due to needing to travel all the
way up th ancestor tree before returning the cvar value. The deeper the
ancestor tree the slower cvar access will be.

The benefits of the cache are more visible with a higher number of
included modules due to the way Ruby looks up class variables. The
benchmark here includes 26 modules and shows with the cache, this branch
is 6.5x faster when accessing class variables.

```
compare-ruby: ruby 3.1.0dev (2021-03-15T06:22:34Z master 9e5105c) [x86_64-darwin19]
built-ruby: ruby 3.1.0dev (2021-03-15T12:12:44Z add-cache-for-clas.. c6be009) [x86_64-darwin19]

|         |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|vm_cvar  |      5.681M|   36.980M|
|         |           -|     6.51x|
```

Benchmark.ips calling `ActiveRecord::Base.logger` from within a Rails
application. ActiveRecord::Base.logger has 71 ancestors. The more
ancestors a tree has, the more clear the speed increase. IE if Base had
only one ancestor we'd see no improvement. This benchmark is run on a
vanilla Rails application.

Benchmark code:

```ruby
require "benchmark/ips"
require_relative "config/environment"

Benchmark.ips do |x|
  x.report "logger" do
    ActiveRecord::Base.logger
  end
end
```

Ruby 3.0 master / Rails 6.1:

```
Warming up --------------------------------------
              logger   155.251k i/100ms
Calculating -------------------------------------
```

Ruby 3.0 with cvar cache /  Rails 6.1:

```
Warming up --------------------------------------
              logger     1.546M i/100ms
Calculating -------------------------------------
              logger     14.857M (± 4.8%) i/s -     74.198M in   5.006202s
```

Lastly we ran a benchmark to demonstate the difference between master
and our cache when the number of modules increases. This benchmark
measures 1 ancestor, 30 ancestors, and 100 ancestors.

Ruby 3.0 master:

```
Warming up --------------------------------------
            1 module     1.231M i/100ms
          30 modules   432.020k i/100ms
         100 modules   145.399k i/100ms
Calculating -------------------------------------
            1 module     12.210M (± 2.1%) i/s -     61.553M in   5.043400s
          30 modules      4.354M (± 2.7%) i/s -     22.033M in   5.063839s
         100 modules      1.434M (± 2.9%) i/s -      7.270M in   5.072531s

Comparison:
            1 module: 12209958.3 i/s
          30 modules:  4354217.8 i/s - 2.80x  (± 0.00) slower
         100 modules:  1434447.3 i/s - 8.51x  (± 0.00) slower
```

Ruby 3.0 with cvar cache:

```
Warming up --------------------------------------
            1 module     1.641M i/100ms
          30 modules     1.655M i/100ms
         100 modules     1.620M i/100ms
Calculating -------------------------------------
            1 module     16.279M (± 3.8%) i/s -     82.038M in   5.046923s
          30 modules     15.891M (± 3.9%) i/s -     79.459M in   5.007958s
         100 modules     16.087M (± 3.6%) i/s -     81.005M in   5.041931s

Comparison:
            1 module: 16279458.0 i/s
         100 modules: 16087484.6 i/s - same-ish: difference falls within error
          30 modules: 15891406.2 i/s - same-ish: difference falls within error
```

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-06-18 10:02:44 -07:00
Hiroshi SHIBATA 9d96837dbd
Bump matrix version to 0.4.2 2021-06-18 19:13:36 +09:00
Nobuyoshi Nakada bdeaa60e7b
Make frozen Time Ractor-shareable 2021-06-18 11:58:15 +09:00
Jeremy Evans 1de063a10b Add section on build requirements to the README
I'm not sure that this is section is complete (may be missing
requirements), or accurate (minimum automake or bison versions
may not be correct).  However, I think it's useful, and we can
adjust it in the future to add requirements or adjust
requirement versions.

Fixes [Bug #14409]
2021-06-18 10:58:27 +09:00
Yusuke Endoh 0a36cab1b5 Enable USE_ISEQ_NODE_ID by default
... which is formally called EXPERIMENTAL_ISEQ_NODE_ID.

See also ff69ef27b0.

https://bugs.ruby-lang.org/issues/17930
2021-06-18 03:35:38 +09:00
Yusuke Endoh dfba87cd62 Make it possible to get AST::Node from Thread::Backtrace::Location
RubyVM::AST.of(Thread::Backtrace::Location) returns a node that
corresponds to the location. Typically, the node is a method call, but
not always.

This change also includes iseq's dump/load support of node_ids for each
instructions.
2021-06-18 03:35:38 +09:00
Yusuke Endoh ea6062898a Remove LOCATION_TYPE_ISEQ_CALCED state from Backtrace::Location
Previously Backtrace::Location had two possible states:
LOCATION_TYPE_ISEQ and LOCATION_TYPE_ISEQ_CALCED. The former had the
location information as PC, and the latter had it as lineno.
Once lineno was caluculated, the state was changed to
LOCATION_TYPE_ISEQ_CALCED and the caluculated result was kept.

This change removes LOCATION_TYPE_ISEQ_CALCED, so lineno is calculated
whenever it is needed. It will be slow a little, but lineno is typically
needed only when its backtrace is shown, so I believe that it does not
matter.

This is a preparation to add column information to Backtrace::Location
because PC is needed to caluculate node_id for AST::Node even after
lineno is calculated. This change is approved by ko1.
2021-06-18 03:35:38 +09:00
git ed3e30fc09 * 2021-06-18 [ci skip] 2021-06-18 02:34:45 +09:00
Yusuke Endoh fb01411ae8 node.h: Reduce struct size to fit with Ruby object size (five VALUEs)
by merging `rb_ast_body_t#line_count` and `#script_lines`.

Fortunately `line_count == RARRAY_LEN(script_lines)` was always
satisfied. When script_lines is saved, it has an array of lines, and
when not saved, it has a Fixnum that represents the old line_count.
2021-06-18 02:34:27 +09:00
Yusuke Endoh acae5f363d ast.rb: RubyVM::AST.parse and .of accepts `save_script_lines: true`
This option makes the parser keep the original source as an array of
the original code lines. This feature exploits the mechanism of
`SCRIPT_LINES__` but records only the specified code that is passed to
RubyVM::AST.of or .parse, instead of recording all parsed program texts.
2021-06-18 02:34:27 +09:00
Peter Zhu c639b58823 Refactor heap_set_increment
heap_set_increment essentially only calls heap_allocatable_pages_set.
They only differ in behaviour when `additional_pages == 0`. However,
this is only possible because heap_extend_pages may return 0. This
commit also changes heap_extend_pages to always return at least 1.
2021-06-17 10:58:48 -04:00
Nobuyoshi Nakada 95ef545997 [rubygems/rubygems] Close then unlink tempfiles on Windows
In ruby/ruby test actions, number of "leaked tempfile" messages
are shown on Windows.

As Windows disallows removing open files, `Tempfile#unlink` fails
silently before `#close`.
Close then unlink by `#close!` instead.

https://github.com/rubygems/rubygems/commit/fe0b88ac30
2021-06-17 12:28:15 +09:00
Nobuyoshi Nakada e4f891ce8d
Adjust styles [ci skip]
* --braces-after-func-def-line
* --dont-cuddle-else
* --procnames-start-lines
* --space-after-for
* --space-after-if
* --space-after-while
2021-06-17 10:13:40 +09:00
git 4e09722637 * 2021-06-17 [ci skip] 2021-06-17 06:09:36 +09:00
git c1a7e86f40 * expand tabs. [ci skip]
Tabs were expanded because the file did not have any tab indentation in unedited lines.
Please update your editor config, and use misc/expand_tabs.rb in the pre-commit hook.
2021-06-17 06:09:26 +09:00
John Hawthorn c10d5085a2 Enable frozen_string_literal in builtin_iseq_load
Currently this has a fairly minor effect as strings are not used heavily
inside the builtins (outside of warnings, requires, and errors).
Hopefully this allows us to use strings in the future where appropriate.
2021-06-16 14:09:09 -07:00