Previously, our compile time check rejected dynamic symbols (e.g. what
String#to_sym could return) even though we could handle them just fine.
The runtime guards for the type of method name was also overly
restrictive and didn't accept dynamic symbols.
Fold the type check into the rb_get_symbol_id() and take advantage of
the guard already checking for 0. This also avoids generating the same
call twice in case the same method name is presented as different
types.
- Don't use `build_options_scopes` We can inline the code here instead
and avoid allocating all the extra arrays.
- Create `pm_scope_node_t` objects with the correct local table, for the
scope node returned from the parser.
Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
```
compiling ../thread.c
In file included from ../thread.c:263:
In file included from ../thread_pthread.c:2870:
../thread_pthread_mn.c:777:43: warning: format specifies type 'unsigned long' but the argument has type 'rb_hrtime_t' (aka 'unsigned long long') [-Wformat]
RUBY_DEBUG_LOG("abs:%lu", abs);
~~~ ^~~
%llu
../vm_debug.h:110:74: note: expanded from macro 'RUBY_DEBUG_LOG'
ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__); \
^~~~~~~~~~~
1 warning generated.
```
Check that multibyte characters are valid using pm_strpbrk. We need
to add a couple of codepaths to ensure all encodings are covered.
Importantly this doesn't check regular expressions, because
apparently you're allowed to have invalid multibyte characters
inside regular expression comment groups/extended mode.
https://github.com/ruby/prism/commit/2857d3e1b5
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
LSPs need this because the protocol dictates that you return code
units for offsets. None of our existing APIs provided that
information, and since we hid the source it's not nearly as useful
for them. Now they can pass an encoding directly to:
* Location#start_code_units_offset
* Location#end_code_units_offset
* Location#start_code_units_column
* Location#end_code_units_column
https://github.com/ruby/prism/commit/4757a2cc06
Co-Authored-By: Vinicius Stock <vinicius.stock@shopify.com>
The allocation could re-embed `orig_str` and invalidate the data
pointer from RSTRING_GETMEM() if the string is embedded.
Found on CI, where the test introduced in 7002e776944 ("Fix
Symbol#inspect for GC compaction") recently failed.
See: <https://github.com/ruby/ruby/actions/runs/7880657560/job/21503019659>
This PR fixes following error when using `version: latest` argument.
```console
$ ruby -rprism -e "p Prism.parse('-> { it }', version: 'latest')"
-e:1:in `parse': invalid version: latest (ArgumentError)
p Prism.parse('-> { it }', version: 'latest')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from -e:1:in `<main>'
```
The argument `version: latest` in the added test is commented as potentially being
better replaced with `version: 3.4.0` in the future.
https://github.com/ruby/prism/commit/27b5c933cb
I was a little rushed and didn't notice that it was still using the
final stack size even though we don't grow the stack before kwrest
handling anymore. Oh well, we got a new test out of it.
Fix: cbdabd5890
* Specialize String#byteslice(a, b)
This adds a specialization for String#byteslice when there are two
parameters.
This makes our protobuf parser go from 5.84x slower to 5.33x slower
```
Comparison:
decode upstream (53738 bytes): 7228.5 i/s
decode protobuff (53738 bytes): 1236.8 i/s - 5.84x slower
Comparison:
decode upstream (53738 bytes): 7024.8 i/s
decode protobuff (53738 bytes): 1318.5 i/s - 5.33x slower
```
* Update yjit/src/codegen.rs
---------
Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Thanks to the new semantics from [ruby-core:115808], `**nil` is now
equivalent to `**{}`. Since the only thing one could do with anonymous
keyword rest parameter is to delegate it with `**`, nil is just as good
as an empty hash. Using nil avoids allocating an empty hash.
This is particularly important for `...` methods since they now use
`**kwrest` under the hood after 4f77d8d328. Most calls don't pass
keywords.
Comparison:
fw_no_kw
post: 9816800.9 i/s
pre: 8570297.0 i/s - 1.15x slower