Граф коммитов

1778 Коммитов

Автор SHA1 Сообщение Дата
Koichi Sasada a4421bd73c Rewrite Ractor synchronization mechanism
This patch rewrites Ractor synchronization mechanism, send/receive
and take/yield.

* API
  * Ractor::Selector is introduced for lightweight waiting
    for many ractors.
* Data structure
  * remove `struct rb_ractor_waiting_list` and use
    `struct rb_ractor_queue takers_queue` to manage takers.
  * remove `rb_ractor_t::yield_atexit` and use
    `rb_ractor_t::sync::will_basket::type` to check the will.
  * add `rb_ractor_basket::p.take` to represent a taking ractor.
* Synchronization protocol
  * For the Ractor local GC, `take` can not make a copy object
    directly so ask to generate the copy from the yielding ractor.
  * The following steps shows what `r1.take` does on `r0`.
    * step1: (r0) register `r0` into `r1`'s takers.
    * step2: (r0) check `r1`'s status and wakeup r0 if `r1` is waiting
             for yielding a value.
    * step3: (r0) sleep until `r1` wakes up `r0`.
  * The following steps shows what `Ractor.yield(v)` on `r1`.
    * step1: (r1) check first takers of `r1` and if there is (`r0`),
             make a copy object of `v` and pass it to `r0` and
             wakes up `r0`.
    * step2: (r1) if there is no taker ractors, sleep until
             another ractor try to take.
2023-03-02 14:31:54 +09:00
Matt Valentine-House 5e4b80177e Update the depend files 2023-02-28 09:09:00 -08:00
Matt Valentine-House f38c6552f9 Remove intern/gc.h from Make deps 2023-02-27 10:11:56 -08:00
Peter Zhu 3e09822407 Fix incorrect line numbers in GC hook
If the previous instruction is not a leaf instruction, then the PC was
incremented before the instruction was ran (meaning the currently
executing instruction is actually the previous instruction), so we
should not increment the PC otherwise we will calculate the source
line for the next instruction.

This bug can be reproduced in the following script:

```
require "objspace"

ObjectSpace.trace_object_allocations_start
a =

  1.0 / 0.0
p [ObjectSpace.allocation_sourceline(a), ObjectSpace.allocation_sourcefile(a)]
```

Which outputs: [4, "test.rb"]

This is incorrect because the object was allocated on line 10 and not
line 4. The behaviour is correct when we use a leaf instruction (e.g.
if we replaced `1.0 / 0.0` with `"hello"`), then the output is:
[10, "test.rb"].

[Bug #19456]
2023-02-24 14:10:09 -05:00
Kaíque Kandy Koga aff41a3669 Add information about runirb in make help 2023-02-24 19:44:36 +09:00
Nobuyoshi Nakada d025ff29c4
Clone bundled gem sources only if GIT is available 2023-02-22 10:23:06 +09:00
Nobuyoshi Nakada 289080e4d8 Clone and create dummy gemspec in sequential build 2023-02-22 02:07:59 +09:00
Jean Boussier 7413079dae Encapsulate RCLASS_ATTACHED_OBJECT
Right now the attached object is stored as an instance variable
and all the call sites that either get or set it have to know how it's
stored.

It's preferable to hide this implementation detail behind accessors
so that it is easier to change how it's stored.
2023-02-15 15:24:22 +01:00
Nobuyoshi Nakada 38ecf08ba1
[DOC] Fix the help messages for clean 2023-02-10 14:46:52 +09:00
Matt Valentine-House 72aba64fff Merge gc.h and internal/gc.h
[Feature #19425]
2023-02-09 10:32:29 -05:00
Nobuyoshi Nakada 899ea35035
Extract include/ruby/internal/attr/packed_struct.h
Split `PACKED_STRUCT` and `PACKED_STRUCT_UNALIGNED` macros into the
macros bellow:
* `RBIMPL_ATTR_PACKED_STRUCT_BEGIN`
* `RBIMPL_ATTR_PACKED_STRUCT_END`
* `RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN`
* `RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END`
2023-02-08 12:34:13 +09:00
Takashi Kokubun 5694515460
Document BUNDLED_GEMS in make test 2023-01-31 15:02:44 -08:00
Alan Wu 7d4395cb69 YJIT: Fix shared/static library symbol leaks
Rust 1.58.0 unfortunately doesn't provide facilities to control symbol
visibility/presence, but we care about controlling the list of
symbols exported from libruby-static.a and libruby.so.

This commit uses `ld -r` to make a single object out of rustc's
staticlib output, libyjit.a. This moves libyjit.a out of MAINLIBS and adds
libyjit.o into COMMONOBJS, which obviates the code for merging libyjit.a
into libruby-static.a. The odd appearance of libyjit.a in SOLIBS is also
gone.

To filter out symbols we do not want to export on ELF platforms, we use
objcopy after the partial link. On darwin, we supply a symbol list to
the linker which takes care of hiding unprefixed symbols.

[Bug #19255]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-01-27 12:28:09 -05:00
Hiroshi SHIBATA 6608d47bed Enable code-coverage result for test-syntax-suggest 2023-01-26 13:52:20 +09:00
Nobuyoshi Nakada 17f5631c6e [Bug #19340] Fix bundle gems with test revision
Build temporary gem package from cloned repository if test revision is
set.
2023-01-26 12:50:39 +09:00
Hiroshi SHIBATA 5e1e5af2e7
Support simplecov-0.22.0.
simplecov-0.22.0 no longer support pre-0.18 result format. result data needs
  `lines` key for coverage data.
2023-01-25 16:47:05 +09:00
Hiroshi SHIBATA 4981206b49
update-coverage needs to build ruby and all C-ext libraries 2023-01-23 15:14:02 +09:00
Nobuyoshi Nakada 569fbf229b
Run `after-update` in the same main make process [ci skip] 2023-01-20 00:21:53 +09:00
Hiroshi SHIBATA d275adde78 Pin simplecov-0.20.0 2023-01-18 20:19:08 +09:00
Hiroshi SHIBATA 18d8333c30 Switch to use gem version of simplecov, not git clone 2023-01-18 20:19:08 +09:00
Takashi Kokubun 5fc97f34c6 benchmark_driver v0.16.3
Some chruby-related features and bug fixes.
2023-01-17 22:26:45 -08:00
Hiroshi SHIBATA 01e28afd0a
test-syntax-suggest is now part of make check 2023-01-17 16:56:57 +09:00
Hiroshi SHIBATA aad1563c1a
Added make exam to help message 2023-01-17 16:50:19 +09:00
Hiroshi SHIBATA da7818e682
Added test-syntax-suggest to help message 2023-01-17 16:48:44 +09:00
Hiroshi SHIBATA ff3c1d9e13
SimpleCov is hosted under simplecov-ruby org now 2023-01-17 14:31:36 +09:00
Alan Wu 14fe7a081a YJIT: Use ThinLTO for Rust parts in release mode
This reduces the code size of libyjit.a by a lot. On darwin it went from
23 MiB to 12 MiB for me. I chose ThinLTO over fat LTO for the relatively
fast build time; in case we need to debug release-build-only problems
it won't be painful.
2023-01-16 17:32:15 -05:00
Nobuyoshi Nakada 088132fb33 Do not depend on `REVISION_H`
Disable for now, since this seems causing infinite rebuilding.
2023-01-15 17:21:59 +09:00
Nobuyoshi Nakada 1ddeb7473d
Move the dependency of makefiles on revision header [ci skip]
Since `REVISION_H` is defined in common.mk which is appended or
included after Makefile.in, it was undefined yet at the point of the
dependency.
2023-01-14 20:30:19 +09:00
Hiroshi SHIBATA fe11bee507
Suppressing installation messages with test-bundler
Ignoring the following messages:

    ```
    (snip)
            -e 'load "spec/bundler/support/bundle.rb"' -- install --gemfile=tool/bundler/dev_gems.rb
    Using rake 13.0.6
    Using bundler 2.5.0.dev
    Using diff-lcs 1.5.0
    Using parallel 1.22.1
    Using parallel_tests 2.32.0
    Using power_assert 2.0.2
    Using rb_sys 0.9.52
    Using rspec-support 3.12.0
    Using rspec-core 3.12.0
    Using rspec-expectations 3.12.0
    Using rspec-mocks 3.12.1
    Using test-unit 3.5.5
    Using uri 0.12.0
    Using webrick 1.7.0
    Bundle complete! 11 Gemfile dependencies, 14 gems now installed.
    Gems in the groups 'lint' and 'doc' were not installed.
    Use `bundle info [gemname]` to see where a bundled gem is installed.
    ```
2023-01-12 10:46:54 +09:00
Hiroshi SHIBATA b311c35bdb Suppressing pending messages with RSpec 2023-01-11 20:00:21 +09:00
Takashi Kokubun df76c54fc2 Allow overriding a gdb command on `make gdb`
With --enable-yjit, you see an annoying warning like this:

warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /home/k0kubun/src/github.com/ruby/ruby/.ruby/miniruby.
Use `info auto-load python-scripts [REGEXP]' to list them.

Using `rust-gdb` instead fixes it. I use this like `make gdb GDB=rust-gdb`.
2023-01-09 16:45:50 -08:00
Yusuke Endoh 4959e01932 common.mk: Do not invoke outdate-bundled-gems by default
If baseruby is available (and its version is different from one being
built) when compiling ruby, tool/outdate-bundled-gems.rb (which is
invoked by `make install`) wrongly deletes debug.so and rbs_extension.so
in .bundle/extension/*.

This leads to a broken installation of ruby which lacks the libraries,
which may make rubygems show the following warnings (in some additional
complex conditions):

```
$ irb
Ignoring debug-1.7.1 because its extensions are not built. Try: gem pristine debug --version 1.7.1
Ignoring rbs-2.8.2 because its extensions are not built. Try: gem pristine rbs --version 2.8.2
irb(main):001:0>
```

According to some committers, tool/outdate-bundled-gems.rb is introduced
for fixing a build issue, but the detail is not recorded. The issue
seems to occur only when debug gem or rbs gem is updated, so it is
difficult to fix the script so soon.

Tentatively, this change stops invoking the script by default.
This should be backported to ruby_3_2.

Fixes [Bug #19271]
2023-01-05 18:26:35 +09:00
Nobuyoshi Nakada c6c7f5900f Test bundler and bundled gems by exam 2022-12-28 09:15:31 +09:00
Nobuyoshi Nakada 84a4f1b3b2 Order test-bundler-parallel dependency 2022-12-28 09:15:31 +09:00
Nobuyoshi Nakada be7cb324a5
Clean yjit directory in build directory [ci skip] 2022-12-25 12:19:23 +09:00
Nobuyoshi Nakada 18c1ca8f4c
Fix test-syntax-suggest order
Prepare for test-syntax-suggest after other tests finished.
2022-12-24 20:18:10 +09:00
Takashi Kokubun b9332ac8e7
MJIT: Cancel all on disastrous situations (#7019)
I noticed this while running test_yjit with --mjit-call-threshold=1, 
which redefines `Integer#<`. When Ruby is monkey-patched, 
MJIT itself could be broken.

Similarly, Ruby scripts could break MJIT in many different ways. I
prepared the same set of hooks as YJIT so that we could possibly
override it and disable it on those moments. Every constant under
RubyVM::MJIT is private and thus it's an unsupported behavior though.
2022-12-24 01:13:40 -08:00
Nobuyoshi Nakada cae5384273 Test syntax_suggest by `make check` 2022-12-23 20:33:27 +09:00
Takashi Kokubun bb4cbd0803
Put RubyVM::MJIT::Compiler under ruby_vm directory (#6989)
[Misc #19250]
2022-12-21 22:46:15 -08:00
Benoit Daloze d557f17974 Use an experimental warning for Fiber#storage= 2022-12-20 19:32:23 +01:00
Nobuyoshi Nakada 5716c0f1f8
MSVS lacks `touch` [ci skip] 2022-12-20 17:53:41 +09:00
Nobuyoshi Nakada 0ccc498e6e
loadpath.c does not depend on revision.h since 947ebd0ac5 2022-12-20 16:06:32 +09:00
Hiroshi SHIBATA 5e5f3f6bd1
Followed up ad18d1297e with tool/update-deps --fix 2022-12-16 13:59:04 +09:00
Peter Zhu c505448cdb Move definition of SIZE_POOL_COUNT back to gc.h
SIZE_POOL_COUNT is a GC macro, it should belong in gc.h and not shape.h.
SIZE_POOL_COUNT doesn't depend on shape.h so we can have shape.h depend
on gc.h.

Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2022-12-15 16:33:46 -05:00
Alan Wu 258ac07907
YJIT: Generate debug info in release builds (#6910)
* YJIT: Generate debug info in release builds

They are helpful in case we need to do core dump debugging.

* Remove Cirrus DOC skip rule

The syntax for this is weird, and escaping [ and ] cause parse failures.
Cirrus' docs said to surround with .*, but then that seems to skip
everything. Revert e0a4205eb7 for now.
2022-12-12 15:59:29 -05:00
Nobuyoshi Nakada 7a976c1060
[Bug #19181] Separate the rule for unicode_normalize/tables.rb timestamp
It should depends on only existing data files (except for the tools),
unless `ALWAYS_UPDATE_UNICODE=yes`.
2022-12-10 13:58:20 +09:00
Jean Boussier 73771e4b19 ObjectSpace.dump_all: dump shapes as well
I see several arguments in doing so.

First they use a non trivial amount of memory, so for various memory
profiling/mapping tools it is relevant to have visibility of the space
occupied by shapes.

Then, some pathological code can create a tons of shape, so it is
valuable to have a way to have a way to observe shapes without having
to compile Ruby with `SHAPE_DEBUG=1`.

And additionally it's likely much faster to dump then this way than
to use `RubyVM::Shape`.

There are however a few open questions:

- Shapes can't respect the `since:` argument. Not sure what to do when
  it is provided. Would probably make sense to not dump them.
- Maybe it would make more sense to have a separate `ObjectSpace.dump_shapes`?
- Maybe instead `dump_all` should take a `shapes: false` argument?

Additionally, `ObjectSpace.dump_shapes` is added for the use case of
debugging the evolution of the shape tree.
2022-12-08 18:46:16 +01:00
Aaron Patterson edc7af48ac Stop transitioning to UNDEF when undefining an instance variable
Cases like this:

```ruby
obj = Object.new
loop do
  obj.instance_variable_set(:@foo, 1)
  obj.remove_instance_variable(:@foo)
end
```

can cause us to use many more shapes than we want (and even run out).
This commit changes the code such that when an instance variable is
removed, we'll walk up the shape tree, find the shape, then rebuild any
child nodes that happened to be below the "targetted for removal" IV.

This also requires moving any instance variables so that indexes derived
from the shape tree will work correctly.

Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com>
Co-authored-by: John Hawthorn <jhawthorn@github.com>
2022-12-07 09:57:11 -08:00
Daniel Colson 64cdf8bae7 Update dependencies 2022-12-06 12:37:23 -08:00
Nobuyoshi Nakada e9a0f45dc4
[Bug #19180] rbconfig.rb depends on common.mk 2022-12-06 11:06:15 +09:00