Commit graph

516 commits

Author SHA1 Message Date
John Hawthorn
f483befd90 Add shape_id to RBasic under 32 bit
This makes `RBobject` `4B` larger on 32 bit systems
but simplifies the implementation a lot.

[Feature #21353]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2025-05-26 10:31:54 +02:00
Samuel Williams
425fa0aeb5
Make waiting_fd behaviour per-IO. (#13127)
- `rb_thread_fd_close` is deprecated and now a no-op.
- IO operations (including close) no longer take a vm-wide lock.
2025-05-13 19:02:03 +09:00
Takashi Kokubun
53a27f114a
YJIT: Split the block on optimized getlocal/setlocal (#13282) 2025-05-12 09:03:46 -07:00
Satoshi Tagomori
382645d440 namespace on read 2025-05-11 23:32:50 +09:00
Takashi Kokubun
cbf9c088f8
YJIT: End the block after OPTIMIZE_METHOD_TYPE_CALL (#13245) 2025-05-05 13:35:28 -07:00
Samuel Williams
06a7b3c144
Only test on known good platforms. (#13123) 2025-04-17 16:19:05 +00:00
Samuel Williams
c4ae6cb500
Prefer th->ec for stack base/size. (#13101) 2025-04-17 13:21:51 +00:00
Naoto Ono
5adb2591da
Skip TestThreadInstrumentation#test_sleeping_inside_ractor on ModGC workflow (#12996)
TestThreadInstrumentation#test_sleeping_inside_ractor is a flaky and failing intermittently. Additionally, Launchable reported this test as a top flaky test. (Link: https://app.launchableinc.com/organizations/ruby/workspaces/ruby/insights/unhealthy-tests)

It failed only failed intermittently on ModGC workflow, so I'm gonna skip this test on ModGC workflow.
2025-03-27 21:22:38 +09:00
Nobuyoshi Nakada
8d6f153fba Manage skipping instance variable IDs in one place 2025-03-17 23:42:16 +09:00
Nobuyoshi Nakada
4a67ef09cc
[Feature #21116] Extract RJIT as a third-party gem 2025-02-13 18:01:03 +09:00
Takashi Kokubun
01db456196 Move Array#map to Ruby
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2024-11-13 12:27:26 -08:00
Hiroshi SHIBATA
a2dd471d9e
macOS 15 is the stable version today 2024-11-06 15:45:32 +09:00
Peter Zhu
77db37813a Fix indentation in test_after_gc_start_hook_with_GC_stress 2024-10-03 11:58:20 -04:00
Hiroshi SHIBATA
baac5376da
Use macos? helper 2024-09-11 18:13:01 +09:00
Satoshi Tagomori
19ec803179 Reset the counter for two consecutive runs 2024-07-31 10:59:51 +09:00
Satoshi Tagomori
6c5c30b542 Use tmpdir for various environments (including Windows) 2024-07-30 15:31:24 +09:00
Satoshi Tagomori
50a0552bd7 Fix test code and extension to avoid using gvars and Kernel methods 2024-07-30 15:31:24 +09:00
Satoshi Tagomori
c884db0b5b [BUG #20655] Add tests to use rb_ensure and call cont.call 2024-07-30 15:31:24 +09:00
Kevin Newton
1c81d1a69d [PRISM] Refactor parser support into its own module 2024-07-18 21:15:54 -04:00
Kevin Newton
76ea5cde2a Refactor RUBY_DESCRIPTION assertions in test_rubyoptions 2024-07-18 13:03:17 -04:00
Hiroshi SHIBATA
371055979f Pend some tests because these are not working with macOS 15 beta and Xcode 16 beta 2024-07-12 13:38:22 +09:00
Jean Boussier
83f57ca3d2 String.new(capacity:) don't substract termlen
[Bug #20585]

This was changed in 36a06efdd9 because
`String.new(1024)` would end up allocating `1025` bytes, but the problem
with this change is that the caller may be trying to right size a String.

So instead, we should just better document the behavior of `capacity:`.
2024-06-19 15:11:07 +02:00
tompng
04467218ce Add rb_str_resize coderange test 2024-06-13 18:27:02 +02:00
Nobuyoshi Nakada
e323dbb1bd
Make subclasses to define methods 2024-06-07 00:50:30 +09:00
Jean Boussier
730e3b2ce0 Stop exposing rb_str_chilled_p
[Feature #20205]

Now that chilled strings no longer appear as frozen, there is no
need to offer an API to check for chilled strings.

We however need to change `rb_check_frozen_internal` to no
longer be a macro, as it needs to check for chilled strings.
2024-06-02 13:53:35 +02:00
Jean Boussier
0b38403328 Fix incorrect assertion in TestThreadInstrumentation
The test meant to assert the thread is suspended at least once,
but was actually asserting to it to be suspected at least twice.
2024-05-20 14:59:59 +09:00
Étienne Barrié
2b08406cd0 Expose rb_str_chilled_p
Some extensions (like stringio) may need to differentiate between
chilled strings and frozen strings.

They can now use rb_str_chilled_p but must check for its presence since
the function will be removed when chilled strings are removed.

[Bug #20389]

[Feature #20205]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-03-26 12:54:54 +01:00
Jean Boussier
09d8c99cdc Ensure test suite is compatible with --frozen-string-literal
As preparation for https://bugs.ruby-lang.org/issues/20205
making sure the test suite is compatible with frozen string
literals is making things easier.
2024-03-14 17:56:15 +01:00
Thomas Marshall
7e4b1f8e19
[Bug #20322] Fix rb_enc_interned_str_cstr null encoding
The documentation for `rb_enc_interned_str_cstr` notes that `enc` can be
a null pointer, but this currently causes a segmentation fault when
trying to autoload the encoding. This commit fixes the issue by checking
for NULL before calling `rb_enc_autoload`.
2024-03-03 10:43:35 +00:00
Koichi Sasada
d578684989 rb_thread_lock_native_thread()
Introduce `rb_thread_lock_native_thread()` to allocate dedicated
native thread to the current Ruby thread for M:N threads.
This C API is similar to Go's `runtime.LockOSThread()`.

Accepted at https://github.com/ruby/dev-meeting-log/blob/master/2023/DevMeeting-2023-08-24.md
(and missed to implement on Ruby 3.3.0)
2024-02-21 15:38:29 +09:00
Yusuke Endoh
9d1b000bd1 Show the method owner in backtraces
```
test.rb:1:in 'Object#toplevel_meth': unhandled exception
        from test.rb:4:in 'Foo.class_meth'
        from test.rb:6:in 'Foo#instance_meth'
        from test.rb:11:in 'singleton_meth'
        from test.rb:13:in '<main>'
```

[Feature #19117]
2024-02-15 19:11:58 +09:00
Yusuke Endoh
25d74b9527 Do not include a backtick in error messages and backtraces
[Feature #16495]
2024-02-15 18:42:31 +09:00
Kevin Newton
b4880af0e2 [PRISM] Fix test_bug_reporter with prism 2024-01-31 14:20:51 -05:00
Hiroshi SHIBATA
1d972498eb Use Encoding::CESU_8 for test case
Encoding::Windows_31J is already loaded in mswin platform
2024-01-25 16:06:06 +09:00
Dylan Thacker-Smith
2b96737636 Fix use of the rb_profile_frames start parameter
Previously, it was decrementing the start argument until it reached
zero without actually changing the control frame pointer.

[Bug #14607]
2023-12-28 08:58:21 -08:00
Satoshi Tagomori
04f7be6126 loading/testing in different processes for multiple runs 2023-12-15 21:36:27 +09:00
Satoshi Tagomori
e51f9e9f75 rb_ext_resolve_symbol: C API to resolve and return externed symbols [Feature #20005]
This is a C API for extensions to resolve and get function symbols of other extensions.
Extensions can check the expected symbol is correctly loaded and accessible, and
use it if it is available.
Otherwise, extensions can raise their own error to guide users to setup their
environments correctly and what's missing.
2023-12-14 17:39:42 +09:00
KJ Tsanaktsidis
a8d2d93aff Add a test case for preregistering with different data
We want to make sure that if preregister is called with different data,
that the postponed job table is updated.
2023-12-13 13:35:05 +11:00
Yusuke Endoh
535eb4de11 Remove unused statement
... to disable a warning: assigned but unused variable - expected
2023-12-12 10:31:37 +09:00
KJ Tsanaktsidis
f8effa209a Change the semantics of rb_postponed_job_register
Our current implementation of rb_postponed_job_register suffers from
some safety issues that can lead to interpreter crashes (see bug #1991).
Essentially, the issue is that jobs can be called with the wrong
arguments.

We made two attempts to fix this whilst keeping the promised semantics,
but:
  * The first one involved masking/unmasking when flushing jobs, which
    was believed to be too expensive
  * The second one involved a lock-free, multi-producer, single-consumer
    ringbuffer, which was too complex

The critical insight behind this third solution is that essentially the
only user of these APIs are a) internal, or b) profiling gems.

For a), none of the usages actually require variable data; they will
work just fine with the preregistration interface.

For b), generally profiling gems only call a single callback with a
single piece of data (which is actually usually just zero) for the life
of the program. The ringbuffer is complex because it needs to support
multi-word inserts of job & data (which can't be atomic); but nobody
actually even needs that functionality, really.

So, this comit:
  * Introduces a pre-registration API for jobs, with a GVL-requiring
    rb_postponed_job_prereigster, which returns a handle which can be
    used with an async-signal-safe rb_postponed_job_trigger.
  * Deprecates rb_postponed_job_register (and re-implements it on top of
    the preregister function for compatability)
  * Moves all the internal usages of postponed job register
    pre-registration
2023-12-10 15:00:37 +09:00
John Hawthorn
9e09e5aa3a Fix test of GVL instrumentation on Ractor sleeping
It seems that the Ractor sleep GVL event arrives very slightly after the
value becomes available and other threads wake (which makes sense) so we
need a little additional time to ensure we end up in a consisteny state.
2023-12-09 12:01:29 -08:00
John Hawthorn
b2ad4fec1a Add missing GVL hooks for M:N threads and ractors 2023-12-09 09:31:41 -08:00
John Hawthorn
85bc80a51b Revert "Add missing GVL hooks for M:N threads and ractors"
This reverts commit ad54fbf281.
2023-12-03 18:37:06 -08:00
John Hawthorn
ad54fbf281 Add missing GVL hooks for M:N threads and ractors
[Bug #20019]

This fixes GVL instrumentation in three locations it was missing:
- Suspending when blocking on a Ractor
- Suspending when doing a coroutine transfer from an M:N thread
- Resuming after an M:N thread starts

Co-authored-by: Matthew Draper <matthew@trebex.net>
2023-12-02 10:06:07 -08:00
Nobuyoshi Nakada
79eb75a8dd
[Bug #20025] Check if upper/lower before fallback to case-folding 2023-11-29 14:40:21 +09:00
Jean Boussier
982641939c Further fix the GVL instrumentation API
Followup: https://github.com/ruby/ruby/pull/9029

[Bug #20019]

Some events still weren't triggered from the right place.

The test suite was also improved a bit more.
2023-11-28 20:06:55 +01:00
Jean Boussier
23a7714343 Refactor and fix the GVL instrumentation API
This entirely changes how it is tested. Rather than to use counters
we now record the timeline of events with associated threads which
makes it much easier to assert that certains events are only preceded
by a specific event, and makes it much easier to debug unexpected
timelines.

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
Co-Authored-By: JP Camara <jp@jpcamara.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2023-11-27 17:37:57 +01:00
Jean Boussier
9ca41e9991 GVL Instrumentation: pass thread->self as part of event data
Context: https://github.com/ivoanjo/gvl-tracing/pull/4

Some hooks may want to collect data on a per thread basis.
Right now the only way to identify the concerned thread is to
use `rb_nativethread_self()` or similar, but even then because
of the thread cache or MaNy, two distinct Ruby threads may report
the same native thread id.

By passing `thread->self`, hooks can use it as a key to store
the metadata.

NB: Most hooks are executed outside the GVL, so such data collection
need to use a thread-safe data-structure, and shouldn't use the
reference in other ways from inside the hook.

They must also either pin that value or handle compaction.
2023-11-13 08:45:20 +01:00
Nobuyoshi Nakada
1910bd4247
String for string literal is not resizable 2023-11-08 00:59:45 +09:00
Takashi Kokubun
9f95b6eb5d Skip a test that is flaky with RJIT
It's crashing inside the bug reporter after a crash, so not sure why
it's crashing. It's not really useful for maintaining RJIT to flag this
test failure, so let's just ignore it until we figure out why it fails.

1835843916
2023-11-03 22:18:16 -07:00