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

476 Коммитов

Автор SHA1 Сообщение Дата
yui-knk d8601621ed Enhance keep_tokens option for RubyVM::AbstractSyntaxTree parsing methods
Implementation for Language Server Protocol (LSP) sometimes needs token information.
For example both `m(1)` and `m(1, )` has same AST structure other than node locations
then it's impossible to check the existence of `,` from AST. However in later case,
it might be better to suggest variables list for the second argument.
Token information is important for such case.

This commit adds these methods.

* Add `keep_tokens` option for `RubyVM::AbstractSyntaxTree.parse`, `.parse_file` and `.of`
* Add `RubyVM::AbstractSyntaxTree::Node#tokens` which returns tokens for the node including tokens for descendants nodes.
* Add `RubyVM::AbstractSyntaxTree::Node#all_tokens` which returns all tokens for the input script regardless the receiver node.

[Feature #19070]

Impacts on memory usage and performance are below:

Memory usage:

```
$ cat test.rb
root = RubyVM::AbstractSyntaxTree.parse_file(File.expand_path('../test/ruby/test_keyword.rb', __FILE__), keep_tokens: true)

$ /usr/bin/time -f %Mkb /usr/local/bin/ruby -v
ruby 3.2.0dev (2022-11-19T09:41:54Z 19070-keep_tokens d3af1b8057) [x86_64-linux]
11408kb

# keep_tokens :false
$ /usr/bin/time -f %Mkb /usr/local/bin/ruby test.rb
17508kb

# keep_tokens :true
$ /usr/bin/time -f %Mkb /usr/local/bin/ruby test.rb
30960kb
```

Performance:

```
$ cat ../ast_keep_tokens.yml
prelude: |
  src = <<~SRC
    module M
      class C
        def m1(a, b)
          1 + a + b
        end
      end
    end
  SRC
benchmark:
  without_keep_tokens: |
    RubyVM::AbstractSyntaxTree.parse(src, keep_tokens: false)
  with_keep_tokens: |
    RubyVM::AbstractSyntaxTree.parse(src, keep_tokens: true)

$ make benchmark COMPARE_RUBY="./ruby" ARGS=../ast_keep_tokens.yml
/home/kaneko.y/.rbenv/shims/ruby --disable=gems -rrubygems -I../benchmark/lib ../benchmark/benchmark-driver/exe/benchmark-driver \
            --executables="compare-ruby::./ruby -I.ext/common --disable-gem" \
            --executables="built-ruby::./miniruby -I../lib -I. -I.ext/common  ../tool/runruby.rb --extout=.ext  -- --disable-gems --disable-gem" \
            --output=markdown --output-compare -v ../ast_keep_tokens.yml
compare-ruby: ruby 3.2.0dev (2022-11-19T09:41:54Z 19070-keep_tokens d3af1b8057) [x86_64-linux]
built-ruby: ruby 3.2.0dev (2022-11-19T09:41:54Z 19070-keep_tokens d3af1b8057) [x86_64-linux]
warming up..

|                     |compare-ruby|built-ruby|
|:--------------------|-----------:|---------:|
|without_keep_tokens  |     21.659k|   21.303k|
|                     |       1.02x|         -|
|with_keep_tokens     |      6.220k|    5.691k|
|                     |       1.09x|         -|
```
2022-11-21 09:01:34 +09:00
Hiroshi SHIBATA a80b66e7eb
Added build instructions of psych and fiddle with source files of libyaml and libffi 2022-11-18 17:51:37 +09:00
Samuel Williams cb4c89e08e
Fix quoting of code in `NEWS.md`. 2022-11-17 15:19:21 -08:00
Samuel Williams ea8a7287e2
Add support for `sockaddr_un` on Windows. (#6513)
* Windows: Fix warning about undefined if_indextoname()

* Windows: Fix UNIXSocket on MINGW and make .pair more reliable

* Windows: Use nonblock=true for read tests with scheduler

* Windows: Move socket detection from File.socket? to File.stat

Add S_IFSOCK to Windows and interpret reparse points accordingly.
Enable tests that work now.

* Windows: Use wide-char functions to UNIXSocket

This fixes behaviour with non-ASCII characters.
It also fixes deletion of temporary UNIXSocket.pair files.

* Windows: Add UNIXSocket tests for specifics of Windows impl.

* Windows: fix VC build due to missing _snwprintf

Avoid usage of _snwprintf, since it fails linking ruby.dll like so:

  linking shared-library x64-vcruntime140-ruby320.dll
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l

whereas linking miniruby.exe succeeds.

This patch uses snprintf on the UTF-8 string instead.

Also remove branch GetWindowsDirectoryW, since it doesn't work.

* Windows: Fix dangling symlink test failures

Co-authored-by: Lars Kanis <kanis@comcard.de>
2022-11-17 14:50:25 -08:00
git 71e668e633 Update default gems list at c76909e551 [ci skip] 2022-11-17 04:53:46 +00:00
Takashi Kokubun d15d1c01c2
Rename --mjit-min-calls to --mjit-call-threshold (#6731)
for consistency with YJIT
2022-11-14 23:38:52 -08:00
git e4e2ff76a8 Update default gems list at d019c3a4bd [ci skip] 2022-11-14 06:38:18 +00:00
Nobuyoshi Nakada bab8051d2d [Bug #19100] [DOC] Add NEWS about PRNG update and incompatiblity 2022-11-11 01:56:46 +09:00
git cdb3ec3af8 Update default gems list at 4e728486b9 [ci skip] 2022-11-08 08:08:48 +00:00
Takashi Kokubun ea77aa2fd0
YJIT: Make Code GC metrics available for non-stats builds (#6665) 2022-11-03 13:41:35 -04:00
git 1acbcf0e58 Update bundled gems list at 2022-10-30 2022-10-30 07:04:08 +00:00
Kazuhiro NISHIYAMA 572cd10a86
Fix links and sort [ci skip] 2022-10-30 00:53:10 +09:00
Takashi Kokubun b795e66a2d
Add NEWS entries about YJIT [ci skip] (#6636) 2022-10-26 10:40:49 -04:00
Takashi Kokubun 1161454806
Add NEWS entries about MJIT [ci skip] 2022-10-25 22:26:20 -07:00
git a733633c57 Update default gems list at d6d9b5130e [ci skip] 2022-10-25 23:14:50 +00:00
git 399747926c Update bundled gems list at 2022-10-24 2022-10-24 09:27:55 +00:00
git 87f432b675 Update default gems list at c5f5403f6e [ci skip] 2022-10-24 05:46:26 +00:00
yui-knk 0d697e341a Add [Feature #19013] to NEWS [ci skip] 2022-10-22 16:46:27 +09:00
Ufuk Kayserilioglu 0378e2f4a8 Add Class#attached_object
Implements [Feature #12084]

Returns the object for which the receiver is the singleton class, or
raises TypeError if the receiver is not a singleton class.
2022-10-20 17:30:17 +02:00
git 93d73cfe80 Update default gems list at dffca50bb6 [ci skip] 2022-10-18 08:22:21 +00:00
git 85cee29357 Update default gems list at 6166fa612c [ci skip] 2022-10-17 07:43:51 +00:00
Nobuyoshi Nakada 15488fc1c6
Update bundled gems list at 2022-10-16 2022-10-16 18:22:20 +09:00
Samuel Williams 8a420670a2
Introduce `Fiber::Scheduler#io_select` hook for non-blocking `IO.select`. (#6559) 2022-10-15 19:59:04 +13:00
Vladimir Dementyev 4954c9fc0f Add MatchData#deconstruct/deconstruct_keys 2022-10-10 12:41:13 +09:00
git 7775d14356 Update bundled gems list at 2022-10-08 2022-10-08 07:05:42 +00:00
Alan Wu d76854f166 Update NEWS about [Feature #18589] 2022-10-07 12:38:43 -04:00
Samuel Williams e4f91bbdba
Add IO#timeout attribute and use it for blocking IO operations. (#5653) 2022-10-07 21:48:38 +13:00
git e76217a7f3 Update bundled gems list at c3a87e16d8 [ci skip] 2022-10-07 07:03:33 +00:00
Hiroshi SHIBATA b84140f607
Mentioned removing libffi sources from fiddle 2022-10-05 18:26:17 +09:00
git 48c261a040 Update default gems list at 203b831065 [ci skip] 2022-10-05 06:25:40 +00:00
git 6378825df5 Update bundled gems list at 2022-10-04 2022-10-04 07:09:33 +00:00
Victor Shepelev ad651925e3
Add Data class implementation: Simple immutable value object 2022-09-30 18:23:19 +09:00
git 4ced7bfb23 Update bundled gems list at 866cfb248e [ci skip] 2022-09-29 12:05:31 +00:00
git 2f7a530f59 Update bundled gems list at 8c4e52fbe8 [ci skip] 2022-09-29 01:28:41 +00:00
Samuel Williams e7ddb6b182
Update NEWS.md with updated coverage interfaces. 2022-09-29 09:44:14 +13:00
Samuel Williams 81b919ce5c Add news for eval coverage. 2022-09-25 20:35:47 +13:00
git 4c37eaa979 Update default gems list at 928aeef330 [ci skip] 2022-09-22 08:31:12 +00:00
Hiroshi SHIBATA f07e651a90
Mentioned new constants for Process and Socket classes on NEWS.md 2022-09-22 14:37:56 +09:00
Mau Magnaguagno 76b4305a59 [DOC] Improve NEWS.md
Fix missing dot and replace error with ArgumentError.
2022-09-21 15:17:12 +09:00
Benoit Daloze acc61cbf4a Add NEWS entry for the previous commit 2022-09-12 14:59:45 +02:00
Benoit Daloze 14bcf69c9c Deprecate Encoding#replicate
* See [Feature #18949].
2022-09-10 19:02:15 +02:00
git 6d10865cc2 Update default gems list at 2657d8efb9 [ci skip] 2022-09-06 01:42:25 +00:00
git 4331d4bbf0 Update default gems list at 113581d288 [ci skip] 2022-09-05 10:06:58 +00:00
Takashi Kokubun 7064d259bc
Update NEWS.md for YJIT 2022-09-01 14:12:24 -07:00
Kazuhiro NISHIYAMA 954f709f4e
NEWS.md: sort [ci skip] 2022-08-22 12:18:58 +09:00
Hiroshi SHIBATA 3d6baad7fa
Added syntax_suggest entry to NEWS 2022-08-22 11:40:38 +09:00
git 61ab06fe8a Update default gems list at 490af8dbdb [ci skip] 2022-08-19 01:03:07 +00:00
git b3718edee2 Update bundled gems list at 2022-08-18 2022-08-18 07:04:23 +00:00
Nobuyoshi Nakada 0617cba197
[DOC] Add the link to [Feature #18809] 2022-08-13 11:23:47 +09:00
Kouhei Yanagita d1d1c9ba7a Add a NEWS entry about Integer#ceildiv [ci skip] 2022-08-13 09:29:15 +09:00