1919 Commits
Author SHA1 Message Date
Hiroshi SHIBATA 44faeab78c test-syntax-suggest is not working with mswin environment 2026-05-19 18:40:27 +09:00
Samuel WilliamsandLuke Gruber 183e2b0a23 Use ec->interrupt_mask to prevent interrupts. [Backport #21610]
Disallow pending interrupts to be checked during `FiberScheduler#unblock`.

Ractors can send signals at any time, so the previous debug assertion can fail if a Ractor sends a signal.

Co-authored-by: Luke Gruber <luke.gruber@shopify.com>
2025-10-06 07:50:39 +09:00
nagachika 868bcf3807 Update dependency for goruby 2025-07-20 18:32:03 +09:00
nagachika 407f6c9d05 merge revision(s) b42afa1dbc, 67b91e7807, f1f0cc14cc, 543e3a1896, ed2806117a, 46e4c86737: [Backport #21497]
Suppress gcc 15 unterminated-string-initialization warnings

	Drop an ignored attribute
	MIME-Version: 1.0
	Content-Type: text/plain; charset=UTF-8
	Content-Transfer-Encoding: 8bit

	GCC 13.3.0 (Ubuntu 24.04) emits the following warning:

	../symbol.c: In function ‘rb_id_attrset’:
	../symbol.c:175:9: warning: ‘nonstring’ attribute ignored on objects of type ‘const char[][8]’ [-Wattributes]
	  175 |         RBIMPL_ATTR_NONSTRING() static const char id_types[][8] = {
	      |         ^~~~~~~~~~~~~~~~~~~~~

	Separate `__has_attribute` from `defined(__has_attribute)`

	Fix Visual C warnings:
	```
	regenc.h(121): warning C4067: unexpected tokens following preprocessor directive - expected a newline
	```

	Cast up `int` instruction code to `VALUE`

	Fix Visual C warnings:
	```
	iseq.c(3793): warning C4312: 'type cast': conversion from 'int' to 'void *' of greater size
	iseq.c(3794): warning C4312: 'type cast': conversion from 'int' to 'void *' of greater size
	```

	Do not let files depend on a phony target

	Detect `clock_gettime` and `clock_getres` for winpthreads
2025-07-20 18:32:03 +09:00
nagachika d5c8fd2043 merge revision(s) f6cbf499bc: [Backport #21354]
Fix Symbol#to_proc (rb_sym_to_proc) to be ractor safe

	In non-main ractors, don't use `sym_proc_cache`. It is not thread-safe
	to add to this array without a lock and also it leaks procs from one
	ractor to another. Instead, we create a new proc each time. If this
	results in poor performance we can come up with a solution later.

	Fixes [Bug #21354]
2025-06-14 11:39:08 +09:00
nagachika 551c444f81 merge revision(s) b48b841378, 2fe8b9cd3d: [Backport #21327]
digest.so needs ruby/digest.h which is installed by build-ext

	Copy to path with the base name
2025-05-18 12:00:23 +09:00
John HawthornandAlan Wu ef523984f0 Replace tombstone when converting AR to ST hash
[Bug #21170]

st_table reserves -1 as a special hash value to indicate that an entry
has been deleted. So that that's a valid value to be returned from the
hash function, do_hash replaces -1 with 0 so that it is not mistaken for
the sentinel.

Previously, when upgrading an AR table to an ST table,
rb_st_add_direct_with_hash was used which did not perform the same
conversion, this could lead to a hash in a broken state where one if its
entries which was supposed to exist being marked as a tombstone.

The hash could then become further corrupted when the ST table required
resizing as the falsely tombstoned entry would be skipped but it would
be counted in num entries, leading to an uninitialized entry at index
15.

In most cases this will be really rare, unless using a very poorly
implemented custom hash function.

This also adds two debug assertions, one that st_add_direct_with_hash
does not receive the reserved hash value, and a second in
rebuild_table_with, which ensures that after we rebuild/compact a table
it contains the expected number of elements.

Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
2025-03-08 16:43:58 +09:00
Hiroshi SHIBATA 7ff601aea0 Lock json-schema-5.1.0 for using pure ruby version 2024-12-03 11:08:37 +09:00
Takashi Kokubun 6db39f4677 merge revision(s) 29c480dd6f: [Backport #20853]
[Bug #20853] Fix Proc#hash to not change after compaction

	The hash value of a Proc must remain constant after a compaction, otherwise
	it may not work as the key in a hash table.
2024-11-04 14:43:39 -08:00
Nobuyoshi Nakada f6e9899e8a Make rbconfig.rb loadable from exe/ruby
So that it can run without `--disable=gems` option.
2023-12-23 18:03:31 +09:00
Nobuyoshi Nakada 8c03bdacd1 Control the precheck for test-all by PRECHECK_TEST_ALL 2023-12-23 18:03:30 +09:00
Nobuyoshi Nakada 7a60196a8e Fix ext/socket/constdefs.c dependency [ci skip] 2023-12-17 20:14:41 +09:00
Nobuyoshi Nakada e0914ed267 Add undocumnted target [ci skip] 2023-12-17 20:00:29 +09:00
HParker 55326a915f Introduce --parser runtime flag
Introduce runtime flag for specifying the parser,

```
ruby --parser=prism
```

also update the description:

```
$ ruby --parser=prism --version
ruby 3.3.0dev (2023-12-08T04:47:14Z add-parser-runtime.. 0616384c9f) +PRISM [x86_64-darwin23]
```

[Bug #20044]
2023-12-15 13:42:19 -05: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
Nobuyoshi Nakada 655aacc43a Use dedicated functions to check terminators 2023-12-11 16:51:46 +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
6816e8efcf Free everything at shutdown
when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2023-12-07 15:52:35 -05:00
Peter Zhu 12e3b07455 Re-embed when removing Object instance variables
Objects with the same shape must always have the same "embeddedness"
(either embedded or heap allocated) because YJIT assumes so. However,
using remove_instance_variable, it's possible that some objects are
embedded and some are heap allocated because it does not re-embed heap
allocated objects.

This commit changes remove_instance_variable to re-embed Object
instance variables when it becomes small enough.
2023-12-06 11:34:07 -05:00
HParker b8b319dd1a Revert "allow enabling Prism via flag or env var"
This reverts commit 9b76c7fc89.
2023-12-06 10:21:12 +09:00
HParker 9b76c7fc89 allow enabling Prism via flag or env var
Enable Prism using either --prism

    ruby --prism test.rb

or via env var

    RUBY_PRISM=1 ruby test.rb
2023-12-05 12:17:14 -05:00
Peter Zhu b9f2c67106 [PRISM] Fix dependencies 2023-12-04 10:27:26 -05:00
Kevin Newton e2bbbacc23 [ruby/prism] Correctly pass around const pm_encoding_t *
https://github.com/ruby/prism/commit/ce4c67fb3a
2023-11-30 21:37:56 -05:00
Kevin Newton b4a85e402f [PRISM] Fix up prism encoding targets 2023-11-30 21:37:56 -05:00
Kevin Newton 14761edbf6 [prism] Add MacJapanese encodings to common.mk 2023-11-29 12:08:15 -05:00
Kevin Newton b549722eef [prism] Add pm_cp950 to make targets 2023-11-29 11:15:50 -05:00
Kevin Newton b45442f8a8 [prism] Add cp949 targets to common.mk 2023-11-22 09:12:35 -05:00
Kevin Newton 73d519ec46 [prism] Remove pm_big5_hkscs from common.mk targets 2023-11-20 21:18:31 -05:00
Aaron Patterson 6fce8c7980 Don't try compacting ivars on Classes that are "too complex"
Too complex classes use a hash table to store ivs, and should always pin
their IVs.  We shouldn't touch those classes in compaction.
2023-11-20 16:09:48 -08:00
Kevin Newton bc744f3f0f [prism] Update common.mk for prism big5 hkscs 2023-11-18 13:53:42 -05:00
Kevin Newton a6548e9eef [prism] Add cp51932 to common.mk 2023-11-16 12:16:43 -05:00
Nobuyoshi Nakada 7e8d9f49b3 [Bug #18286] Show checksum of builtin_binary.inc for confirmation 2023-11-09 16:01:01 +09:00
Nobuyoshi Nakada 22939382a8 [Bug #18286] Make builtin binary if sharable in universal binaries 2023-11-09 16:01:01 +09:00
Nobuyoshi Nakada 40d40a651e Revert "Disable iseq-dumped builtin module for universal x86_64/arm64 binaries"
This reverts commit 1d5598fe0d.
2023-11-09 16:01:01 +09:00
Ben Hamilton 1d5598fe0d Disable iseq-dumped builtin module for universal x86_64/arm64 binaries
During the build, Ruby has special logic to serialize its own builtin
module to disk using the binary iseq format during the build (I assume
for speed so it doesn't have to parse builtin every time it starts
up).

However, since iseq format is architecture-specific, when building on
x86_64 for universal x86_64 + arm64, the serialized builtin module is
written with the x86_64 architecture of the build machine, which fails
this check whenever ruby imports the builtin module on arm64:

https://github.com/ruby/ruby/blob/1fdaa0666086529b3aae2d509a2e71c4247c3a12/compile.c#L13243

Thankfully, there's logic to disable this feature for cross-compiled builds:

https://github.com/ruby/ruby/blob/1fdaa0666086529b3aae2d509a2e71c4247c3a12/builtin.c#L6

This disables the iseq logic for universal builds as well.

Fixes [Bug #18286]
2023-11-09 12:24:01 +09:00
Kevin Newton ec86b2eb39 [prism] Update to use new options APIs 2023-11-03 10:13:50 -04:00
Kevin Newton 90b21b864d [prism] Updates for sync 2023-11-01 13:10:29 -04:00
Kevin Newton 719b40bdf6 [prism] Update prettyprint deps 2023-10-26 15:47:01 -04:00
Jemma Issroff 8f71a5c530 [PRISM] Move scope_node itself to CRuby, create prism_compile.h 2023-10-25 18:18:35 -03:00
ydah e6fcf07a6f Use -H option instead of -h option
Follow up: https://github.com/ruby/lrama/pull/139
2023-10-23 17:04:27 +09:00
Nobuyoshi Nakada 665b4c5b2a [Bug #19967] Reset LIBPATHENV env after started
Not to affect other tools invoked as child processes.
2023-10-21 14:05:20 +09:00
d2b0c9da2e YJIT: Add a live ISeq counter
It's an estimator for application size and could be used as a
compilation heuristic later.

Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-10-18 23:46:35 +00:00
Nobuyoshi Nakada 4c54492770 Separate test-precheck target
So that the tests can run without updating other than the programs.
2023-10-17 21:07:25 +09:00
Nobuyoshi Nakada 03ac10898f Wait for showflag to finish to prevent interspersed outputs 2023-10-17 21:07:25 +09:00
yui-knk 448e8b5ebb Remove duplicated option
`-d` option is basically same with `-h` (`--header`).
The difference is `-h` accept header file name.
Therefore remove `-d` option.
2023-10-17 08:09:49 +09:00
Kevin Newton 17697c968e [prism] Remove unused make target 2023-10-13 15:34:59 -04:00
Kevin Newton b5ee570eb8 [prism] Remove unescape targets 2023-10-13 15:31:30 -04:00
Jemma Issroff d705885286 [PRISM] Add --dump=prism mode (#8643) 2023-10-13 12:24:40 -07:00
Koichi Sasada be1bbd5b7d M:N thread scheduler for Ractors
This patch introduce M:N thread scheduler for Ractor system.

In general, M:N thread scheduler employs N native threads (OS threads)
to manage M user-level threads (Ruby threads in this case).
On the Ruby interpreter, 1 native thread is provided for 1 Ractor
and all Ruby threads are managed by the native thread.

From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means
1 Ruby thread has 1 native thread. M:N scheduler change this strategy.

Because of compatibility issue (and stableness issue of the implementation)
main Ractor doesn't use M:N scheduler on default. On the other words,
threads on the main Ractor will be managed with 1:1 thread scheduler.

There are additional settings by environment variables:

`RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor.
Note that non-main ractors use the M:N scheduler without this
configuration. With this configuration, single ractor applications
run threads on M:1 thread scheduler (green threads, user-level threads).

`RUBY_MAX_CPU=n` specifies maximum number of native threads for
M:N scheduler (default: 8).

This patch will be reverted soon if non-easy issues are found.

[Bug #19842]
2023-10-12 14:47:01 +09:00
Kevin Newton a213d21448 Move CRuby-specific prism files to top level 2023-09-28 09:44:16 -04:00