79677 Commits

Author SHA1 Message Date
Peter Zhu
775df74feb [DOC] Fix link in NEWS.md 2023-08-24 21:45:34 -04:00
Samuel Williams
40d774bec6
Avoid memory dependency between instructions. (#8284) 2023-08-25 13:28:33 +12:00
Takashi Kokubun
97a97d6d6c mv test/bom_test.rb test/yarp/
This sync 0e3dc5a056abf51363070ad94de4a8097bc80197 wasn't successful.
2023-08-24 15:05:04 -07:00
Burdette Lamar
f9aea75747
[DOC] RDoc for Process (#8282) 2023-08-24 17:41:43 -04:00
Alan Wu
ebb9034710 Remove cfp parameter from hook_before_rewind()
It's only used once, and it has to equal `ec->cfp`, so just use that.
2023-08-24 17:37:07 -04:00
Alan Wu
05e827427f Make cfp constant and use it more in vm_exec_handle_exception()
For writing THROW_DATA_VAL, being able to see that it's writing to the
same frame after modifying PC and SP is nice.
2023-08-24 17:37:07 -04:00
Alan Wu
5937a0da80 YJIT: Refactor to use Option<BlockHandler> in SpecVal
We pass block around as `Option<BlockHandler>` having SpecVal
match that simplifes code matching for the `None` case.
2023-08-24 17:35:10 -04:00
Alan Wu
f61e620c4d YJIT: Move block handler SpecVal variants into BlockHandler
A refactor so that the variants correspond to
branches in vm_caller_setup_arg_block().
2023-08-24 17:35:10 -04:00
Kevin Newton
0e3dc5a056 [ruby/yarp] Fix lex compat with BOM
* BOM should not impact looking for the encoding string
* We should re-encode tokens when the encoding changes
* BOM should change the column of comments only

https://github.com/ruby/yarp/commit/119fc2d7b2
2023-08-24 21:30:01 +00:00
Kevin Newton
90048241ca [ruby/yarp] A couple small stylistic updates for yp_scope_node
* Ensure the node gets initialized in case of failure with no assertions
* Include lambda and top-level nodes for scopes
* Small indentation fixes

https://github.com/ruby/yarp/commit/be29e07391
2023-08-24 19:27:22 +00:00
Jemma Issroff
90ff30e51e [ruby/yarp] Requested changes
https://github.com/ruby/yarp/commit/eb01ea17c1
2023-08-24 19:06:02 +00:00
Jemma Issroff
82d84d741e [ruby/yarp] Added BlockNode case to ScopeNode, fixed ScopeNode to have body
https://github.com/ruby/yarp/commit/8bd3f59621
2023-08-24 19:06:01 +00:00
Jemma Issroff
ef82054bb5 [ruby/yarp] Added ModuleNode
https://github.com/ruby/yarp/commit/29754d818b
2023-08-24 19:06:01 +00:00
Jemma Issroff
82e1434ef6 [ruby/yarp] Pulled scope node out of config.yml, added necessary void returns
https://github.com/ruby/yarp/commit/926e6bdd88
2023-08-24 19:06:00 +00:00
Jemma Issroff
d81634d3ef [ruby/yarp] Add a ScopeNode and a way to create scope nodes from existing nodes
This commit creates a scope node, and exposes a method to get
ScopeNodes from other existing nodes. It still has TODOs around
creating ScopeNodes for other types of nodes, which will be
done in future commits.

https://github.com/ruby/yarp/commit/3b9ac5764d
2023-08-24 19:06:00 +00:00
Burdette Lamar
75c9c2c431
[DOC] Process doc (#8279) 2023-08-24 13:46:14 -04:00
HParker
58ca0cfa07 [ruby/yarp] Fix backslash-r (CR) delimited strings
now CR can be used as a string delimiter

https://github.com/ruby/yarp/commit/3d27bad797
2023-08-24 16:05:50 +00:00
Kevin Newton
791d572ba8 [ruby/yarp] A couple of small stylistic changes
* `le_len` to `eol_length`
* Braces on the same line as switch case
* `peek_addr` -> `peek_at`
* `peek_at` -> `peek_offset`
* `match_line_ending_addr` -> `match_eol_at`
* `match_line_ending_at` -> `match_eol_offset`

https://github.com/ruby/yarp/commit/d7ffa9e64e
2023-08-24 16:05:37 +00:00
Kevin Newton
432702a427 [ruby/yarp] Encoding-dependent escapes
https://github.com/ruby/yarp/commit/36a5b801c4
2023-08-24 11:56:16 -04:00
Kevin Newton
9aba46c666
Sync YARP to c175f712522cc315f45cd2da308768b90f324dd0 2023-08-24 11:56:09 -04:00
Stan Lo
e1d7066a5f [ruby/irb] Deprecate RubyLex and warn about referencing to it
(https://github.com/ruby/irb/pull/692)

`RubyLex` has always been a private component of IRB, so we should
explicitly discourage usages of it.
Also, it should be placed under the `IRB` module like other components.

https://github.com/ruby/irb/commit/069b5625f7
2023-08-24 15:35:40 +00:00
Mike Dalessio
20927a89c2 [ruby/yarp] Improve handling of line endings
Introduce three new inline helper functions:

- `match_line_ending`
- `match_line_ending_at`
- `match_line_ending_addr`

These functions are similar in signature to the `peek*` functions, but
return the length of the line ending being inspected (or 0 if no line
ending was found).

These functions are then used to simplify how we're detecting line
endings throughout "src/yarp.c".

Also:
- test coverage backfilled for `__END__` comments with CRLF line endings.
- error message for invalid `%` tokens updated to not include
  the potential line endings.
- some small refactorings for readability along the way

https://github.com/ruby/yarp/commit/a00067386d
2023-08-24 13:45:29 +00:00
Nobuyoshi Nakada
5ec1fc52c1
Escape non-ascii characters in prelude C comments
Non-ASCII code are often warned by localized compilers.
2023-08-24 21:12:51 +09:00
Nobuyoshi Nakada
554b370b72
Generate sources before checks 2023-08-24 21:12:51 +09:00
Bo Anderson
84a12d6578 Fix compile error on older systems without clock_get* 2023-08-24 19:09:06 +09:00
Nobuyoshi Nakada
fbe7962b54 [ruby/open-uri] Close leaked files
https://github.com/ruby/open-uri/commit/c52ee9e430
2023-08-24 05:14:56 +00:00
Burdette Lamar
7e0d2c6143
[DOC] RDoc for Process (#8253) 2023-08-23 23:21:44 -04:00
Samuel Williams
d4c720a91b
Fix support for dynamic keys. (#8273)
* Skip RBS test.
2023-08-24 15:19:33 +12:00
Jeremy Evans
bd22bb259c Handle Array#* raising ArgumentError in test
Treat ArgumentError as NoMemoryError, so it will resize the array
and try again.

Fixes [Bug #12500]
2023-08-23 16:46:20 -07:00
yui-knk
ce79887da0 The first arg of NEW_KW_ARG macro is always 0 2023-08-24 07:47:52 +09:00
Alan Wu
2214bcb70d Fix premature string collection during append
Previously, the following crashed due to use-after-free
with AArch64 Alpine Linux 3.18.3 (aarch64-linux-musl):

```ruby
str = 'a' * (32*1024*1024)
p({z: str})
```

32 MiB is the default for `GC_MALLOC_LIMIT_MAX`, and the crash
could be dodged by setting `RUBY_GC_MALLOC_LIMIT_MAX` to large values.
Under a debugger, one can see the `str2` of rb_str_buf_append()
getting prematurely collected while str_buf_cat4() allocates capacity.

Add GC guards so the buffer of `str2` lives across the GC run
initiated in str_buf_cat4().

[Bug #19792]
2023-08-23 18:07:49 -04:00
Takashi Kokubun
d7f1ea7155 Quarantine a very flaky spec
https://github.com/ruby/ruby/actions/runs/5956398507/job/16157091112

This has been extremely flaky on macOS GitHub Actions.
Benoit suggested to quarantine it if it's too problematic (it is) and
there's no reasonable fix in a short time (it already took too long).
So this commit follows the suggestion.

We should remove revert this once rb_cloexec_open() is fixed.
2023-08-23 14:32:26 -07:00
Jeremy Evans
43c2c1ed48 [ruby/open-uri] Make URI.open pass keywords
Fixes [Bug #19238]

https://github.com/ruby/open-uri/commit/f636d01b85
2023-08-23 21:30:16 +00:00
Takashi Kokubun
544488f114 Improve comments in sync_default_gems 2023-08-23 14:22:47 -07:00
HParker
cdbc70d088 [ruby/yarp] Match EOF after newline behavior
in Ripper EOL after whitespace is returned as a on_nl node with the whitespace as the content

k0kubun: This is a resync of 9aca3528aa1a1545468a508b02b77bc922bb7321.
git.ruby-lang.org had an old git version and the diff was wrong.
It now has a newer git, so this should succeed next time.

https://github.com/ruby/yarp/commit/be16d1deed
2023-08-23 14:16:12 -07:00
Takashi Kokubun
455297d652 Use https for remotes by default
I was testing this script on git.ruby-lang.org to use its git version,
but it did not work because the server's default user doesn't have SSH
keys.

https works for everyone, so it's a safer default. You shouldn't need to
push to that remote from ruby/ruby anyway.
2023-08-23 13:56:49 -07:00
Takashi Kokubun
c6a07cc33f Ignore more files for other gems as well
e.g. bin/ for reline that was included in its last commit.
2023-08-23 13:43:47 -07:00
Takashi Kokubun
eb795b0325 Avoid sync rule duplication between YARP and others 2023-08-23 13:35:41 -07:00
Kevin Newton
f33c412ebc [ruby/yarp] Constant paths followed by an & should be lexed as a call
https://github.com/ruby/yarp/commit/b0a2ba2c4d
2023-08-23 18:29:25 +00:00
Jean Boussier
cedb333063 Stop incrementing jit_entry_calls once threshold is hit
Otherwise the ISeq page will constantly be written
into preventing it from being shared.
2023-08-23 20:20:17 +02:00
Kevin Newton
24bcd49473 [ruby/yarp] Fix first method param lex failures
When Ripper encounters a method parameter that is the first
parameter and is an identifier and it shadows a local scope, it
incorrectly marks it as END|LABEL (because it think it's a local).

We need to account for that in the lex compat in order to properly
compare.

https://github.com/ruby/yarp/commit/15f725a1b1
2023-08-23 18:06:49 +00:00
Takashi Kokubun
5766fb7266 Fix gdb.py for C frames [ci skip] 2023-08-23 10:59:23 -07:00
HParker
9aca3528aa [ruby/yarp] Match EOF after newline behavior
in Ripper EOL after whitespace is returned as a on_nl node with the whitespace as the content

https://github.com/ruby/yarp/commit/be16d1deed
2023-08-23 17:23:15 +00:00
Rafael Mendonça França
774845284f Change yjit stats list to be a unordered list
Without using a list, this show as a single paragraph with all stats descriptions being in one single line
2023-08-23 19:20:55 +02:00
Kevin Newton
c837e1adfb [ruby/yarp] Add LABEL lex state when lexing a keyword params
https://github.com/ruby/yarp/commit/422bcd0ebf
2023-08-23 16:07:37 +00:00
Mike Dalessio
9c43ec621d [ruby/yarp] fix: newline tracking for a comment at EOF
https://github.com/ruby/yarp/commit/62fb0bddf5
2023-08-23 15:42:20 +00:00
Mike Dalessio
8f0a8e579d [ruby/yarp] Remove unnecessary loop
https://github.com/ruby/yarp/commit/86e8741ee3
2023-08-23 15:40:21 +00:00
Alan Wu
b4bc047f2f
YJIT: Implement VM_CALL_ARGS_BLOCKARG with Proc for ISeq calls
Rack uses this. Speculate that the `obj` in `the_call(&obj)`
will be a proc when the compile-time sample is a proc.

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2023-08-23 11:10:52 -04:00
Mike Dalessio
f902df128d [ruby/yarp] refactor: extract peek_addr()
In many places in the code we use the idiom:

    x < parser->end && *x == 'y'

which is essentially an extension of an existing pattern:

- `peek()` looks at `parser->current.end`
- `peek_at()` looks at `(parser->current.end + offset)`

This commit introduces a new inline function, `peek_addr`, which
accepts a pointer and encapsulates the address value check and
conditional dereferencing. The result is more readable code, and more
ubiquitous safety checks on pointer values, allowing us to rewrite the
above as:

    peek_addr(parser, x) == 'y'

Also:

- change the type of `peek_at()`'s offset argument from `size_t` to
  `ptrdiff_t` so that it can accept negative offsets.
- use `current_token_starts_line` in one place where the equivalent
  code is inline.
- use `peek` or `peek_at` to replace inline code in a few places

These changes simplify the code and make it easier to visually spot
patterns, particularly around line-endings (which will be a subject of
a future pull request).

https://github.com/ruby/yarp/commit/4c608d53ea
2023-08-23 15:08:35 +00:00
Aaron Patterson
58c1ebb634
Fix guard-heap upgrades (#8264)
* Fix guard-heap upgrades

`getinstancevariable` was generating more heap guards than I thought.
It turns out that the upgrade code has a bug in it.

Given the following Ruby code:

```ruby
class Foo
  def initialize
    @a = 1
    @b = 1
  end

  def foo
    [@a, @b]
  end
end

foo = Foo.new
10.times { foo.foo }

puts RubyVM::YJIT.disasm Foo.instance_method(:foo)
```

Before this commit, the machine code was like this:

```
== BLOCK 1/4, ISEQ RANGE [0,3), 36 bytes ======================
  # Insn: 0000 getinstancevariable (stack_size: 0)
  0x5562fb831023: mov rax, qword ptr [r13 + 0x18]
  # guard object is heap
  0x5562fb831027: test al, 7
  0x5562fb83102a: jne 0x5562fb833080
  0x5562fb831030: test rax, rax
  0x5562fb831033: je 0x5562fb833080
  # guard shape
  0x5562fb831039: cmp dword ptr [rax + 4], 0x18
  0x5562fb83103d: jne 0x5562fb833062
  # reg_temps: 00000000 -> 00000001
  0x5562fb831043: mov rsi, qword ptr [rax + 0x10]

== BLOCK 2/4, ISEQ RANGE [3,6), 0 bytes =======================
== BLOCK 3/4, ISEQ RANGE [3,6), 36 bytes ======================
  # regenerate_branch
  # Insn: 0003 getinstancevariable (stack_size: 1)
  # regenerate_branch
  0x5562fb831047: mov rax, qword ptr [r13 + 0x18]
  # guard object is heap
  0x5562fb83104b: test al, 7
  0x5562fb83104e: jne 0x5562fb8330db
  0x5562fb831054: test rax, rax
  0x5562fb831057: je 0x5562fb8330db
  # guard shape
  0x5562fb83105d: cmp dword ptr [rax + 4], 0x18
  0x5562fb831061: jne 0x5562fb8330ba
  # reg_temps: 00000001 -> 00000011
  0x5562fb831067: mov rdi, qword ptr [rax + 0x18]
```

After this commit, the machine code has fewer guards for `self`:

```
== BLOCK 1/4, ISEQ RANGE [0,3), 36 bytes ======================
  # Insn: 0000 getinstancevariable (stack_size: 0)
  0x55cb5db5f023: mov rax, qword ptr [r13 + 0x18]
  # guard object is heap
  0x55cb5db5f027: test al, 7
  0x55cb5db5f02a: jne 0x55cb5db61080
  0x55cb5db5f030: test rax, rax
  0x55cb5db5f033: je 0x55cb5db61080
  # guard shape
  0x55cb5db5f039: cmp dword ptr [rax + 4], 0x18
  0x55cb5db5f03d: jne 0x55cb5db61062
  # reg_temps: 00000000 -> 00000001
  0x55cb5db5f043: mov rsi, qword ptr [rax + 0x10]

== BLOCK 2/4, ISEQ RANGE [3,6), 0 bytes =======================
== BLOCK 3/4, ISEQ RANGE [3,6), 18 bytes ======================
  # regenerate_branch
  # Insn: 0003 getinstancevariable (stack_size: 1)
  # regenerate_branch
  0x55cb5db5f047: mov rax, qword ptr [r13 + 0x18]
  # guard shape
  0x55cb5db5f04b: cmp dword ptr [rax + 4], 0x18
  0x55cb5db5f04f: jne 0x55cb5db610ba
  # reg_temps: 00000001 -> 00000011
  0x55cb5db5f055: mov rdi, qword ptr [rax + 0x18]
```

Co-Authored-By: Takashi Kokubun <takashikkbn@gmail.com>

* Fix array/string guards as well

---------

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-08-23 10:34:03 -04:00