Commit graph

93369 commits

Author SHA1 Message Date
Nobuyoshi Nakada
0aae9e2afa
[DOC] irb is a bundled gem now 2025-08-04 02:02:33 +09:00
Jean Boussier
a12914b516 pathname_buitin.rb: Remove useless o modifier 2025-08-03 17:28:16 +02:00
Lars Kanis
dc10c92749 Revert to shell execution when invoking nm tool
This reverts a change of commit b3598cf2a3 .
On Windows on ARM64 with LLVM the "NM" tool is called with a parameter like so:
```
  RbConfig::CONFIG["NM"] # => "llvm-nm --no-llvm-bc"
```

Therefore the command must be called with a shell string.
2025-08-03 23:43:58 +09:00
Nobuyoshi Nakada
deb0240ea0 [ruby/optparse] Expand literal home paths only
Paths in environment variables should already be expanded.
The base name of the program is also not subject to expansion.

181752391c
2025-08-03 13:53:27 +00:00
Nobuyoshi Nakada
1619afb350 [ruby/optparse] Fallback HOME
e0fdabf946
2025-08-03 13:53:27 +00:00
Stan Lo
30a20bc166 ZJIT: Reject builtin annotation if its iseq has multiple invokebuiltin insns 2025-08-01 17:44:39 -07:00
Stan Lo
44dee185aa ZJIT: Annotate Kernel#class 2025-08-01 17:44:39 -07:00
Stan Lo
3c1ca509b8 ZJIT: Improve builtin function annotation collection 2025-08-01 17:44:39 -07:00
Stan Lo
85510fc2ff ZJIT: Support annotating builtin functions
This allows us to annotate builtin functions with their return type.
2025-08-01 17:44:39 -07:00
Takashi Kokubun
19cbf8406a
ZJIT: Enable IncrCounter for arm64 (#14086) 2025-08-01 17:37:00 -07:00
Alan Wu
3ad6bba136 ZJIT: Refer to scratch registers in operands
Co-authored-by: Takashi Kokubun <takashi.kokubun@shopify.com>
2025-08-01 17:56:15 -04:00
Alan Wu
afac226478 ZJIT: Fix side-exit panicking when there's too many locals
Previously, ARM64 panicked due to compiled_side_exits() when the memory
displacement got large enough to exceed the 9 bits limit. Usually, we split
these kind of memory operands, but compiled_side_exits() runs after
split.

Using scratch registers, implement `Insn::Store` on ARM such that it can
handle large displacements without split(). Do this for x86 as well, and
remove arch specific code from compiled_side_exits(). We can now run
`TestKeywordArguments`.

Since `Insn::Store` doesn't need splitting now, users enjoy lower
register pressure.

Downside is, using `Assembler::SCRATCH_REG` as a base register is now
sometimes an error, depending on whether `Insn::Store` also needs to
use the register. It seems a fair trade off since `SCRATCH_REG` is
not often used, and we don't put it as a base register anywhere at the
moment.
2025-08-01 17:56:15 -04:00
Alan Wu
f58fca7de0 ZJIT: A64: Use MOVN for small negative immediates
Save a couple instructions to load a small negative constant into a
register. In fact MOVN is speced to alias as `mov` in the official
disassembly.
2025-08-01 17:32:01 -04:00
John Hawthorn
faa67506e5 Ensure CC entries always marked, add missing WB
Previously we were issuing writebarriers for each cc, but were missing
the cme.

We also need to avoid it being possible to run GC after we've copied the
values into the allocated array, but before they're visible in the
object.
2025-08-01 13:45:29 -07:00
Jean Boussier
bc789ca804 Convert rb_class_cc_entries.entries in a flexible array member
`rb_class_cc_entries` is little more than a `len` and `capa`.
Hence embedding the entries doesn't cost much extra copying and
saves a bit of memory and some pointer chasing.

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2025-08-01 19:49:38 +02:00
Justin Collins
c6dd3cefa1 [ruby/prism] Avoid monkey patching Sexp#== in RubyParser tests
7362b114a3
2025-08-01 16:57:18 +00:00
Justin Collins
885862a853 [ruby/prism] Match RubyParser behavior for -> lambda args
9f55551b09
2025-08-01 16:57:17 +00:00
Justin Collins
d289eb2723 [ruby/prism] RubyParser translation for stabby lambdas with it
c2e372a8d8
2025-08-01 16:57:17 +00:00
Jean Boussier
fca2e6f8f5 variable.c: Fix rb_ivar_foreach to not yield object_id of complex objects
Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2025-08-01 18:00:05 +02:00
Peter Zhu
bf2c8ad383 Remove dead rb_ractor_t in ractor_selector 2025-08-01 09:43:24 -04:00
Kazuki Yamaguchi
497782856a [ruby/openssl] pkcs7: make PKCS7#add_recipient actually useful
Add a simple test case that creates an enveloped-data structure without
using the shorthand method, and fix two issues preventing this from
working correctly.

First, OpenSSL::PKey::PKCS7#add_recipient currently inserts an
incomplete PKCS7_RECIP_INFO object into the PKCS7 object. When
duplicating an unfinalized PKCS7_RECIP_INFO, the internal X509 reference
must also be copied, as it is later used by #add_data to fill the rest.

A similar issue with #add_signer was fixed in commit 20ca7a27a8
(pkcs7: keep private key when duplicating PKCS7_SIGNER_INFO,
2021-03-24).

Second, #add_data calls PKCS7_dataFinal(), which for enveloped-data
appears to require the BIO to be flushed explicitly with BIO_flush().
Without this, the last block of the encrypted data would be missing.

9595ecf643
2025-08-01 12:04:06 +00:00
Kazuki Yamaguchi
046780179b [ruby/openssl] pkcs7: refactor error handling in PKCS7#add_data
Raise an exception right after an OpenSSL function returns an error.
Checking ERR_peek_error() is not reliable way to see if an error has
occurred or not, as OpenSSL functions do not always populate the error
queue.

cc3f1af73e
2025-08-01 12:04:06 +00:00
Kazuki Yamaguchi
3fe4ab0d23 [ruby/openssl] pkcs7: fix error queue leak in OpenSSL::PKCS7#detached
Only call PKCS7_get_detached() if the PKCS7 object is a signed-data.
This is only useful for the content type, and leaves an error entry if
called on a PKCS7 object with a different content type.

8997f6d5e6
2025-08-01 12:03:39 +00:00
Jean Boussier
1064c63643 Fix rb_shape_transition_object_id transition to TOO_COMPLEX
If `get_next_shape_internal` fail to return a shape, we must
transitiont to a complex shape. `shape_transition_object_id`
mistakenly didn't.

Co-Authored-By: Peter Zhu <peter@peterzhu.ca>
2025-08-01 12:39:14 +02:00
Jean Boussier
547f111b5b Refactor vm_lookup_cc to allow lock-free lookups in RClass.cc_tbl
In multi-ractor mode, the `cc_tbl` mutations use the RCU pattern,
which allow lock-less reads.

Based on the assumption that invalidations and misses should be
increasingly rare as the process ages, locking on modification
isn't a big concern.
2025-08-01 10:42:04 +02:00
Jean Boussier
f2a7e48dea Make RClass.cc_table a managed object
For now this doesn't change anything, but now that the table
is managed by GC, it opens the door to use RCU when in multi-ractor
mode, hence allow unsynchornized reads.
2025-08-01 10:42:04 +02:00
Jean Boussier
fc5e1541e4 Use rb_gc_mark_weak for cc->klass.
One of the biggest remaining contention point is `RClass.cc_table`.
The logical solution would be to turn it into a managed object, so
we can use an RCU strategy, given it's read heavy.

However, that's not currently possible because the table can't
be freed before the owning class, given the class free function
MUST go over all the CC entries to invalidate them.

However if the `CC->klass` reference is weak marked, then the
GC will take care of setting the reference to `Qundef`.
2025-08-01 10:42:04 +02:00
Peter Zhu
1055e04e28 Remove useless set of dest_shape_id in rb_obj_copy_ivar 2025-07-31 23:22:25 -04:00
Takashi Kokubun
543f8dcad3
ZJIT: Add the ISEQ name to Block asm comments (#14070) 2025-07-31 14:28:08 -07:00
Alan Wu
5a7be72c06 Also include shape type in assert
The assert also fails on interpreter-only runs:
4714861028
2025-07-31 16:23:24 -04:00
Takashi Kokubun
12306c0c6f
ZJIT: Stub JIT-to-JIT calls (#14052) 2025-07-31 12:57:59 -07:00
Jean Boussier
f0c31c5e64 Get rid of RSHAPE_PARENT in favor of RSHAPE_DIRECT_CHILD_P
`RSHAPE_PARENT` is error prone because it returns a raw untagged
shape_id.

To check if a shape is a direct parent of another, tags should be
discarded. So providing a comparison function is better than exposing
untagged ids.
2025-07-31 21:55:51 +02:00
Alan Wu
84ee71df45 Print shape id when a flaky shapes assert fails
This has been failing intermittently during
`test_marshal_with_ivar_and_id` for ZJIT and YJIT builds.

4714097060
4714140911
2025-07-31 15:30:46 -04:00
Alan Wu
da0de3cb87 ZJIT: A64: Fix splitting for large memory displacements
On the ruby side, this fixes a crash for methods with 39 or more
parameters. We used to miscomp those entry points due to Insn::Lea
picking ADDS which cannot reference SP:

    # set method params: 40
    mov x0, #0xfee8
    movk x0, #0xffff, lsl #16
    movk x0, #0xffff, lsl #32
    movk x0, #0xffff, lsl #48
    adds x0, xzr, x0

Have Lea work for all i32 displacements and avoid involving the split
pass. Previously, direct use of Insn::Lea directly from the user (as
opposed to generated by the split pass for some memory operations)
wasn't split, so being able to handle the whole range in arm64_emit()
was implicitly required. Also, not going through split reduces register
pressure.
2025-07-31 13:45:20 -04:00
Alan Wu
0aabbbe31d ZJIT: Remove false comment [ci skip] 2025-07-31 13:45:20 -04:00
Alan Wu
214d587a77 ZJIT: Only build the assembler for target_arch
Fixes test error from running the ARM assembler on x86, but then trying
to disassemble it as x86.
2025-07-31 13:45:20 -04:00
Alan Wu
dd352461da ZJIT: A64: Add add_extended() which can add a register to sp 2025-07-31 13:45:20 -04:00
Kazuki Yamaguchi
865a6191d0 [ruby/openssl] pkcs7: clean up tests
This includes:

 - Update test keys to the generic rsa-{1,2,3}.pem.
 - Add omissions for enveloped-data tests so that the rest can be
   tested in the FIPS mode.
 - Add tests for PKCS7#error_string and #data.
 - Check more error paths.
 - Various style fixes.

58f0022de3
2025-07-31 17:38:36 +00:00
Kazuki Yamaguchi
69ff8f736b [ruby/openssl] pkcs7: only set error_string in the error path
Set the error_string attribute to nil if PKCS7_verify() succeeds, since
the error queue should be empty in that case.

With AWS-LC, OpenSSL::PKCS#verify currently sets error_string to
"invalid library (0)" when the verification succeeds, whereas with
OpenSSL and LibreSSL, it becomes nil. ERR_reason_error_string() appears
to behave differently when an invalid error code is passed.

The branch to raise OpenSSL::PKCS7::PKCS7Error is removed because it
does not appear to be reachable.

c11c6631fa
2025-07-31 17:38:35 +00:00
Peter Zhu
771804248e Make ARGF not pin references during marking
ARGF supports compaction, but it pins all of its references, which means
that none of it can move. This commit changes it to actually support
compaction.
2025-07-31 12:46:51 -04:00
Nobuyoshi Nakada
b3598cf2a3 Win: Strip CRs from cpp and nm output
The combination of mingw tools and cygin/msys2 ruby leaves CRs.
2025-08-01 00:15:27 +09:00
Peter Zhu
6c24904a69 Make static symbol ID atomic
We don't need the VM lock if we make static symbol IDs atomic.
2025-07-31 11:09:03 -04:00
Nobuyoshi Nakada
68a03167a5 Suppress maybe-uninitialized warnings 2025-07-31 23:07:08 +09:00
Peter Zhu
05353ab4b7 Make cross_ractor_require write barrier protected 2025-07-31 09:14:22 -04:00
BurdetteLamar
6f7a4f9c96 [DOC] Tweaks for String#getbyte 2025-07-31 09:14:11 -04:00
BurdetteLamar
d7bc1378d2 [DOC] Tweaks for String#force_encoding 2025-07-31 09:13:57 -04:00
BurdetteLamar
6d466a55bd [DOC] Tweaks for String#eql? 2025-07-31 09:13:36 -04:00
BurdetteLamar
ff6a8e95b7 [DOc] Tweaks for String#end_with? 2025-07-31 09:13:20 -04:00
Burdette Lamar
e2bd36388f
[DOC] Tweak for String#encode 2025-07-31 09:13:01 -04:00
Kazuki Yamaguchi
0d3d296b85 Reapply "[ruby/openssl] x509: disallow ossl_x509{,attr,crl,ext,revoked,name}*_new(NULL)"
This reverts commit ec01cd9bbb.

This should no longer break the tests, now that the following changes
have been applied:

 - RubyGems change: 32977f3869
 - ruby/openssl change: e8261963c7
2025-07-31 18:45:53 +09:00