Commit graph

2011 commits

Author SHA1 Message Date
Takashi Kokubun
478e0fc710
YJIT: Replace Array#each only when YJIT is enabled (#11955)
* YJIT: Replace Array#each only when YJIT is enabled

* Add comments about BUILTIN_ATTR_C_TRACE

* Make Ruby Array#each available with --yjit as well

* Fix all paths that expect a C location

* Use method_basic_definition_p to detect patches

* Copy a comment about C_TRACE flag to compilers

* Rephrase a comment about add_yjit_hook

* Give METHOD_ENTRY_BASIC flag to Array#each

* Add --yjit-c-builtin option

* Allow inconsistent source_location in test-spec

* Refactor a check of BUILTIN_ATTR_C_TRACE

* Set METHOD_ENTRY_BASIC without touching vm->running
2024-11-04 11:14:28 -05:00
Peter Zhu
29c480dd6f [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-01 10:49:50 -04:00
Nobuyoshi Nakada
eedb9ac7b8
Tweaks for actions groups 2024-11-01 02:33:11 +09:00
Nobuyoshi Nakada
cc893edaf2
Fetch gem sources to be tested only 2024-11-01 02:33:11 +09:00
Nobuyoshi Nakada
0fda818bd7
Make gemspec files for default gems with extensions
So that rubygems can find them as gems.  However, the `--install-dir`
option of `gem install` seems to exclude prerelease gems, even already
installed in that directory, from the dependencies for some reasons;
use the `GEM_HOME` environment variable instead.

Now net-imap 0.5.0 depends on json gem.
2024-11-01 02:33:10 +09:00
Samuel Williams
87fb44dff6
Introduce Fiber Scheduler blocking_region hook. (#11963) 2024-10-31 17:26:37 +13:00
Hiroshi SHIBATA
7889b88838
We can't install simplecov-json because this depends C ext gem.
Revert "net-imap 0.5.0 needs simplecov-json"

This reverts commit bafcbfe363.
2024-10-29 16:30:41 +09:00
Hiroshi SHIBATA
bafcbfe363
net-imap 0.5.0 needs simplecov-json
3220113312 (step):13:258
2024-10-29 16:25:17 +09:00
Nobuyoshi Nakada
83568a41af Install simplecov for net-imap 0.5.0 test 2024-10-28 23:39:39 +09:00
Matt Valentine-House
1634280e1c Fix shared GC with -DRUBY_DEBUG
RUBY_DEBUG enables ractor assertions, which sets up some space at the
end of each RVALUE to store the associated ractor ID. We need to make
sure the function that does this is visible to shared GC libraries.
2024-10-24 16:08:46 +01:00
Matt Valentine-House
84ec06533d Fix shared-gc build task
include CPPFLAGS, and the correct CFLAGS
2024-10-24 16:08:46 +01:00
Nobuyoshi Nakada
02101f473b
rdoc-srcdir: Adjust the version number in the title in .rdoc_options
Other command line options are no longer needed usually.
2024-10-08 23:43:02 +09:00
Nobuyoshi Nakada
d8b64eac55 rb_fix_mul_fix needs internal/bits.h for MUL_OVERFLOW_FIXNUM_P 2024-10-08 23:29:49 +09:00
Samuel Williams
c50298d7d4
Introduce rb_io_blocking_region which takes struct rb_io argument. (#11795)
This does not change any actual behaviour, but provides a choke point for blocking IO operations.

* Update `IO::Buffer` to use `rb_io_blocking_region`.

* Update `File` to use `rb_io_blocking_region`.

* Update `IO` to use `rb_io_blocking_region`.
2024-10-05 15:10:12 +13:00
Peter Zhu
cd71fa96ac Remove else case for shared-gc make target 2024-10-03 15:45:03 -04:00
Nobuyoshi Nakada
3e1021b144 Make default parser enum and define getter/setter 2024-10-02 20:43:40 +09:00
Nobuyoshi Nakada
5139a574aa
Make directory for shared-GC libraries at build 2024-09-30 00:19:16 +09:00
Kevin Newton
8edd6e606f
Update deps for prism/options.c 2024-09-24 08:37:19 -04:00
Nobuyoshi Nakada
7be1fafe58
Refactor Time#xmlschema
And refine uncommon date cases.

# Iteration per second (i/s)

|                            |compare-ruby|built-ruby|
|:---------------------------|-----------:|---------:|
|time.xmlschema              |      5.020M|   14.192M|
|                            |           -|     2.83x|
|utc_time.xmlschema          |      6.454M|   15.331M|
|                            |           -|     2.38x|
|time.xmlschema(6)           |      4.216M|   10.043M|
|                            |           -|     2.38x|
|utc_time.xmlschema(6)       |      5.486M|   10.592M|
|                            |           -|     1.93x|
|time.xmlschema(9)           |      4.294M|   10.340M|
|                            |           -|     2.41x|
|utc_time.xmlschema(9)       |      4.784M|   10.909M|
|                            |           -|     2.28x|
|fraction_sec.xmlschema(10)  |    366.982k|    3.406M|
|                            |           -|     9.28x|
|future_time.xmlschema       |    994.595k|   15.853M|
|                            |           -|    15.94x|
2024-09-23 14:29:25 +09:00
Nobuyoshi Nakada
ac960b08ee
Clean up dummped IBF files 2024-09-09 00:51:41 +09:00
Nobuyoshi Nakada
ecb58a8d08
Fix prelude to use IBF
Since universal-parser and prism support, prelude code used functions
inaccessible from outside libruby shared library.

```
linking goruby
/usr/bin/ld: goruby.o: in function `prelude_eval':
/home/runner/work/ruby/ruby/build/golf_prelude.c:221: undefined reference to `rb_ruby_prism_ptr'
/usr/bin/ld: goruby.o: in function `pm_prelude_load':
/home/runner/work/ruby/ruby/build/golf_prelude.c:192: undefined reference to `pm_options_line_set'
/usr/bin/ld: /home/runner/work/ruby/ruby/build/golf_prelude.c:193: undefined reference to `pm_parse_string'
/usr/bin/ld: goruby.o: in function `prelude_eval':
/home/runner/work/ruby/ruby/build/golf_prelude.c:224: undefined reference to `pm_iseq_new_with_opt'
/usr/bin/ld: /home/runner/work/ruby/ruby/build/golf_prelude.c:226: undefined reference to `pm_parse_result_free'
/usr/bin/ld: goruby.o: in function `prelude_ast_value':
/home/runner/work/ruby/ruby/build/golf_prelude.c:181: undefined reference to `rb_ruby_ast_data_get'
/usr/bin/ld: goruby.o: in function `prelude_eval':
/home/runner/work/ruby/ruby/build/golf_prelude.c:231: undefined reference to `rb_ruby_ast_data_get'
/usr/bin/ld: goruby.o: in function `pm_prelude_load':
/home/runner/work/ruby/ruby/build/golf_prelude.c:196: undefined reference to `pm_parse_result_free'
collect2: error: ld returned 1 exit status
```
2024-09-08 23:40:17 +09:00
Peter Zhu
0bff07644b
Make YJIT a GC root rather than an object (#11343)
YJIT currently uses the YJIT root object to mark objects during GC and
update references during compaction. This object otherwise serves no
purpose.

This commit changes it YJIT to be step when marking the GC root. This
saves some memory from being allocated from the system and the GC.
2024-08-08 12:19:35 -04:00
Jun Aruga
aed468ae0b CI: Run annocheck for libruby.so
When building with the `--shared` option, most functionality is kept in
`libruby.so`. Therefore also run annocheck for `libruby.so`.

Use `ARG IN_DIR` to propagate multiple files into the container instead of
`ARG FILES` in the `Dockerfile-copy`. Because the `COPY` syntax in Dockerfile
doesn't support copying the multiple files.
https://stackoverflow.com/questions/61599384/specify-multiple-files-in-arg-to-copy-in-dockerfile

Co-authored-by: Vít Ondruch <vondruch@redhat.com>
2024-08-07 18:51:20 +02:00
Alan Wu
0ada02abe2 Put the default GC implementation back into gc.o
We discovered that having gc.o and gc_impl.o in separate translation
units diminishes codegen quality with GCC 11 on x86-64. This commit
solves that problem by including default/gc.c into gc.c, letting the
optimizer have visibility into the body of functions again in builds
not using link-time optimization, which are common.

This effectively restores things to the way they were before
[Feature #20470] from the optimizer's perspective while maintaining the
ability to build gc/default.c as a DSO.

There were a few functions duplicated across gc.c and gc/default.c.
Extract them and put them into gc/gc.h.
2024-07-26 11:44:34 -04:00
Peter Zhu
db3472d84c Set BUILDING_SHARED_GC when building shared GC 2024-07-16 09:09:41 -04:00
Peter Zhu
461a7b8316 Add gc/gc.h for functions in gc.c and used by GC implementations 2024-07-15 08:57:14 -04:00
Matt Valentine-House
f543c68e1c Provide GC.config to disable major GC collections
This feature provides a new method `GC.config` that configures internal
GC configuration variables provided by an individual GC implementation.

Implemented in this PR is the option `full_mark`: a boolean value that
will determine whether the Ruby GC is allowed to run a major collection
while the process is running.

It has the following semantics

This feature configures Ruby's GC to only run minor GC's. It's designed
to give users relying on Out of Band GC complete control over when a
major GC is run. Configuring `full_mark: false` does two main things:

* Never runs a Major GC. When the heap runs out of space during a minor
  and when a major would traditionally be run, instead we allocate more
  heap pages, and mark objspace as needing a major GC.
* Don't increment object ages. We don't promote objects during GC, this
  will cause every object to be scanned on every minor. This is an
  intentional trade-off between minor GC's doing more work every time,
  and potentially promoting objects that will then never be GC'd.

The intention behind not aging objects is that users of this feature
should use a preforking web server, or some other method of pre-warming
the oldgen (like Nakayoshi fork)before disabling Majors. That way most
objects that are going to be old will have already been promoted.

This will interleave major and minor GC collections in exactly the same
what that the Ruby GC runs in versions previously to this. This is the
default behaviour.

* This new method has the following extra semantics:
  - `GC.config` with no arguments returns a hash of the keys of the
    currently configured GC
  - `GC.config` with a key pair (eg. `GC.config(full_mark: true)` sets
    the matching config key to the corresponding value and returns the
    entire known config hash, including the new values. If the key does
    not exist, `nil` is returned

* When a minor GC is run, Ruby sets an internal status flag to determine
  whether the next GC will be a major or a minor. When `full_mark:
  false` this flag is ignored and every GC will be a minor.

  This status flag can be accessed at
  `GC.latest_gc_info(:needs_major_by)`. Any value other than `nil` means
  that the next collection would have been a major.

  Thus it's possible to use this feature to check at a predetermined
  time, whether a major GC is necessary and run one if it is. eg. After
  a request has finished processing.

  ```ruby
  if GC.latest_gc_info(:needs_major_by)
    GC.start(full_mark: true)
  end
  ```

[Feature #20443]
2024-07-12 14:43:33 +01:00
Peter Zhu
00d0ddd48a Add gc/gc_impl.h for GC implementation headers 2024-07-12 08:41:33 -04:00
Peter Zhu
a0469a4788 Rename gc/gc_impl.c to gc/default.c
Changing the name makes it clear that this is the default GC in Ruby.
2024-07-11 09:09:47 -04:00
Peter Zhu
e5d12f9cce Move gc_impl.c to gc/gc_impl.c
This commit creates a new directory `gc` to put different GC
implementations and moves the default GC from gc_impl.c to gc/gc_impl.c.
The default GC can be easily switched using the `BUILTIN_GC` variable
in Makefile.in.
2024-07-11 09:09:47 -04:00
Peter Zhu
a9f6bd028a Add make target shared-gc
Allows building shared GC using `make shared-gc SHARED_GC=gc_impl`
2024-07-08 16:47:25 -04:00
Jean Boussier
9594db0cf2 Implement Hash.new(capacity:)
[Feature #19236]

When building a large hash, pre-allocating it with enough
capacity can save many re-hashes and significantly improve
performance.

```
/opt/rubies/3.3.0/bin/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
	            --executables="compare-ruby::../miniruby-master -I.ext/common --disable-gem" \
	            --executables="built-ruby::./miniruby --disable-gem" \
	            --output=markdown --output-compare -v $(find ./benchmark -maxdepth 1 -name 'hash_new' -o -name '*hash_new*.yml' -o -name '*hash_new*.rb' | sort)
compare-ruby: ruby 3.4.0dev (2024-03-25T11:48:11Z master f53209f023) +YJIT dev [arm64-darwin23]
last_commit=[ruby/irb] Cache RDoc::RI::Driver.new (https://github.com/ruby/irb/pull/911)
built-ruby: ruby 3.4.0dev (2024-03-25T15:29:40Z hash-new-rb 77652b08a2) +YJIT dev [arm64-darwin23]
warming up...

|                    |compare-ruby|built-ruby|
|:-------------------|-----------:|---------:|
|new                 |      7.614M|    5.976M|
|                    |       1.27x|         -|
|new_with_capa_1k    |     13.931k|   15.698k|
|                    |           -|     1.13x|
|new_with_capa_100k  |     124.746|   148.283|
|                    |           -|     1.19x|
```
2024-07-08 12:24:33 +02:00
Peter Zhu
9d3a58f364 [Feature #20470] Update dependencies 2024-07-03 09:03:40 -04:00
Peter Zhu
51bd816517 [Feature #20470] Split GC into gc_impl.c
This commit splits gc.c into two files:

- gc.c now only contains code not specific to Ruby GC. This includes
  code to mark objects (which the GC implementation may choose not to
  use) and wrappers for internal APIs that the implementation may need
  to use (e.g. locking the VM).

- gc_impl.c now contains the implementation of Ruby's GC. This includes
  marking, sweeping, compaction, and statistics. Most importantly,
  gc_impl.c only uses public APIs in Ruby and a limited set of functions
  exposed in gc.c. This allows us to build gc_impl.c independently of
  Ruby and plug Ruby's GC into itself.
2024-07-03 09:03:40 -04:00
Kevin Newton
fa038f838f [PRISM] Strip out common.mk for pm_string_list 2024-06-05 14:40:03 -04:00
Jean Boussier
7c12169230 Eliminate internal uses of Data_Wrap_Struct
Ref: https://github.com/ruby/ruby/pull/10872

These should be the last internal uses of the old `Data` API
inside Ruby itself. Some use remain in a couple default gems.
2024-06-02 13:59:11 +02:00
Nobuyoshi Nakada
26bd4144f7
Add nightly recipe
Installs the last revision in the previous `RUBY_RELEASE_DATE`.
2024-06-02 18:36:09 +09:00
Nobuyoshi Nakada
0d44e23831
Prevent test-bundled-gems outputs from mixing
Run test-bundled-gems-run and test-bundled-gems-spec sequentially.
2024-05-26 22:17:57 +09:00
Kevin Newton
6c07aa364d [PRISM] Remove old prism spec workflow, just use default.mspec now 2024-05-20 12:28:47 -04:00
Hiroshi SHIBATA
9df3f205b1 test-syntax-suggest is not working with mswin environment 2024-05-09 15:22:53 +09:00
卜部昌平
c844968b72 ruby tool/update-deps --fix 2024-04-27 21:55:28 +09:00
Kevin Newton
d3a7e55542
Update common.mk dependencies 2024-04-24 15:45:23 -04:00
Kevin Newton
58847b7df8 [PRISM] Generate inspect_visitor in common.mk 2024-04-24 14:16:42 -04:00
Nobuyoshi Nakada
66edc33f4e
[DOC] Wait for docs to complete before installing all
The document directories may be incomplete or empty before `docs` is
completed.
2024-04-24 12:06:20 +09:00
yui-knk
2992e1074a Refactor parser compile functions
Refactor parser compile functions to reduce the dependence
on ruby functions.
This commit includes these changes

1. Refactor `gets`, `input` and `gets_` of `parser_params`

Parser needs two different data structure to get next line, function (`gets`) and input data (`input`).
However `gets_` is used for both function (`call`) and input data (`ptr`).
`call` is used for managing general callback function when `rb_ruby_parser_compile_generic` is used.
`ptr` is used for managing the current pointer on String when `parser_compile_string` is used.
This commit changes parser to used only `gets` and `input` then removes `gets_`.

2. Move parser_compile functions and `gets` functions from parse.y to ruby_parser.c

This change reduces the dependence on ruby functions from parser.

3. Change ruby_parser and ripper to take care of `VALUE input` GC mark

Move the responsibility of calling `rb_gc_mark` for `VALUE input` from parser to ruby_parser and ripper.
`input` is arbitrary data pointer from the viewpoint of parser.

4. Introduce rb_parser_compile_array function

Caller of `rb_parser_compile_generic` needs to take care about GC because ruby_parser doesn’t know
about the detail of `lex_gets` and `input`.
Introduce `rb_parser_compile_array` to reduce the complexity of ast.c.
2024-04-23 07:20:22 +09:00
yui-knk
d07df8567e Parser and universal parser share wrapper functions 2024-04-20 18:08:33 +09:00
Nobuyoshi Nakada
c789e4c493
Use isolated temporary directory in test-all too for RubyGems tests 2024-04-19 23:06:46 +09:00
Nobuyoshi Nakada
801e4a4feb
Remove UPDATE_LIBRARIES
It has not been used since e48375c112.
2024-04-19 14:12:42 +09:00
Kevin Newton
51485e63fc [PRISM] Generate the reflection file 2024-04-17 13:54:29 -04:00
Kevin Newton
8c8068c06f [PRISM] Remove old make targets for state stack 2024-04-17 10:36:52 -04:00