Age | Commit message (Collapse) | Author |
|
Originally, if a class was defined with the class keyword, the cref had a
const_added callback, and the superclass an inherited callback, const_added was
called first, and inherited second.
This was discussed in
https://bugs.ruby-lang.org/issues/21143
and an attempt at changing this order was made.
While both constant assignment and inheritance have happened before these
callbacks are invoked, it was deemed nice to have the same order as in
C = Class.new
This was mostly for alignment: In that last use case things happen at different
times and therefore the order of execution is kind of obvious, whereas when the
class keyword is involved, the order is opaque to the user and it is up to the
interpreter.
However, soon in
https://bugs.ruby-lang.org/issues/21193
Matz decided to play safe and keep the existing order.
This reverts commits:
de097fbe5f3df105bd2a26e72db06b0f5139bc1a
de48e47ddf78aba02fd9623bc7ce685540a10743
Notes:
Merged: https://github.com/ruby/ruby/pull/13085
|
|
Using `rb_obj_clone` introduce other problems, such as `initialize_*`
callbacks invocation in the context of the parent ractor.
So we can revert back to copy the content of the object slots,
but in a way that is aware of size pools.
Notes:
Merged: https://github.com/ruby/ruby/pull/13070
|
|
[Bug #20271]
[Bug #20267]
[Bug #20255]
`rb_obj_alloc(RBASIC_CLASS(obj))` will always allocate from the basic
40B pool, so if `obj` is larger than `40B`, we'll create a corrupted
object when we later copy the shape_id.
Instead we can use the same logic than ractor copy, which is
to use `rb_obj_clone`, and later ask the GC to free the original
object.
We then must turn it into a `T_OBJECT`, because otherwise
just changing its class to `RactorMoved` leaves a lot of
ways to keep using the object, e.g.:
```
a = [1, 2, 3]
Ractor.new{}.send(a, move: true)
[].concat(a) # Should raise, but wasn't.
```
If it turns out that `rb_obj_clone` isn't performant enough
for some uses, we can always have carefully crafted specialized
paths for the types that would benefit from it.
Notes:
Merged: https://github.com/ruby/ruby/pull/13008
|
|
[Misc #21143]
[Bug #21193]
The previous change caused a backward compatibility issue with code
that called `Object.const_source_location` from the `inherited` callback.
To fix this, the order is now:
- Define the constant
- Invoke `inherited`
- Invoke `const_set`
Notes:
Merged: https://github.com/ruby/ruby/pull/12956
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12947
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12819
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12742
|
|
We can use rb_gc_vm_weak_table_foreach for reference updating of weak tables
in the default GC.
Notes:
Merged: https://github.com/ruby/ruby/pull/12629
|
|
Previously, generic ivars worked differently than the other global tables
during compaction. The other global tables had their references updated
through iteration during rb_gc_update_vm_references. Generic ivars updated
the keys when the object moved and updated the values while reference
updating the object. This is inefficient as this required one lookup for
every moved object and one lookup for every object with generic ivars.
Instead, this commit changes it to iterate over the generic ivar table to
update both the keys and values.
Notes:
Merged: https://github.com/ruby/ruby/pull/12607
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12451
|
|
The keys are IDs, so we cannot update references on them.
Notes:
Merged: https://github.com/ruby/ruby/pull/12371
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12315
|
|
So that it doesn't get included in the generated binaries for builds
that don't support loading shared GC modules
Co-Authored-By: Peter Zhu <[email protected]>
Notes:
Merged: https://github.com/ruby/ruby/pull/12149
|
|
ASAN_OPTIONS="detect_leaks=1" RUBY_FREE_AT_EXIT=1 ./miniruby -e 'trace_var(:$x){}'
Notes:
Merged: https://github.com/ruby/ruby/pull/12146
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12114
|
|
* Use FL_USER0 for ELTS_SHARED
This makes space in RString for two bits for chilled strings.
* Mark strings returned by `Symbol#to_s` as chilled
[Feature #20350]
`STR_CHILLED` now spans on two user flags. If one bit is set it
marks a chilled string literal, if it's the other it marks a
`Symbol#to_s` chilled string.
Since it's not possible, and doesn't make much sense to include
debug info when `--debug-frozen-string-literal` is set, we can't
include allocation source, but we can safely include the symbol
name in the warning message, making it much easier to find the source
of the issue.
Co-Authored-By: Étienne Barrié <[email protected]>
---------
Co-authored-by: Étienne Barrié <[email protected]>
Co-authored-by: Jean Boussier <[email protected]>
|
|
Many libraries should be loaded on the main ractor because of
setting constants with unshareable objects and so on.
This patch allows to call `requore` on non-main Ractors by
asking the main ractor to call `require` on it. The calling ractor
waits for the result of `require` from the main ractor.
If the `require` call failed with some reasons, an exception
objects will be deliverred from the main ractor to the calling ractor
if it is copy-able.
Same on `require_relative` and `require` by `autoload`.
Now `Ractor.new{pp obj}` works well (the first call of `pp` requires
`pp` library implicitly).
[Feature #20627]
Notes:
Merged: https://github.com/ruby/ruby/pull/11142
|
|
Module#name shows up as a top C method callee in lobsters so probably
common enough. It's also easy to substitute thanks to rb_mod_name()
already having no GC yield points.
klass = BasicObject
50_000_000.times { klass.name }
Benchmark 1: /.rubies/post/bin/ruby --yjit mod_name.rb
Time (mean ± σ): 1.433 s ± 0.010 s [User: 1.410 s, System: 0.010 s]
Range (min … max): 1.421 s … 1.449 s 10 runs
Benchmark 2: /.rubies/mstr/bin/ruby --yjit mod_name.rb
Time (mean ± σ): 1.491 s ± 0.012 s [User: 1.468 s, System: 0.010 s]
Range (min … max): 1.470 s … 1.511 s 10 runs
Summary
/.rubies/post/bin/ruby --yjit mod_name.rb ran
1.04 ± 0.01 times faster than /.rubies/mstr/bin/ruby --yjit mod_name.rb
|
|
rb_gen_ivtbl_get locks the VM, but the VM must be locked during marking
so we can directly read from the generic_ivtbl without locking the VM.
Notes:
Merged: https://github.com/ruby/ruby/pull/11785
|
|
And move it back to a public header because Doxygen might not be
scanning the .c files.
[Feature #18776]
Notes:
Merged: https://github.com/ruby/ruby/pull/11179
|
|
This removes the use of symbol and array objects when freeing the global
table so we can now free symbols and arrays earlier.
|
|
[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.
|
|
|
|
|
|
This matches the existing style in the rest of the file.
|
|
|
|
|
|
|
|
[Bug #20188]
Ref: https://github.com/fxn/zeitwerk/issues/281#issuecomment-1893228355
Previously, it would only return the real constant location once the
autoload was fully completed.
|
|
This `st_table` is used to both mark and pin classes
defined from the C API. But `vm->mark_object_ary` already
does both much more efficiently.
Currently a Ruby process starts with 252 rooted classes,
which uses `7224B` in an `st_table` or `2016B` in an `RArray`.
So a baseline of 5kB saved, but since `mark_object_ary` is
preallocated with `1024` slots but only use `405` of them,
it's a net `7kB` save.
`vm->mark_object_ary` is also being refactored.
Prior to this changes, `mark_object_ary` was a regular `RArray`, but
since this allows for references to be moved, it was marked a second
time from `rb_vm_mark()` to pin these objects.
This has the detrimental effect of marking these references on every
minors even though it's a mostly append only list.
But using a custom TypedData we can save from having to mark
all the references on minor GC runs.
Addtionally, immediate values are now ignored and not appended
to `vm->mark_object_ary` as it's just wasted space.
|
|
This frees FL_USER0 on both T_MODULE and T_CLASS.
Note: prior to this, FL_SINGLETON was never set on T_MODULE,
so checking for `FL_SINGLETON` without first checking that
`FL_TYPE` was `T_CLASS` was valid. That's no longer the case.
|
|
Signed-off-by: cui fliter <[email protected]>
|
|
|
|
|
|
[Feature #16495]
|
|
|
|
xfree can handle null values, so we don't need to check it.
|
|
If the autoload_data has autoload_const and the autoload_data is freed
before the autoload_const, then the autoload_data will leak.
This commit changes it so that when the autoload_data is freed, it will
clear the whole linked list of autoload_const so that the autoload_data
can be safely freed.
1000.times do |i|
str = "foo#{i}".freeze
autoload(:"B#{i}", str)
autoload(:"C#{i}", str)
end
Reports leaked memory with the macOS leaks tool:
12 ruby 0x1006398a4 rb_f_autoload + 96 load.c:1524
11 ruby 0x100639710 rb_mod_autoload + 112 load.c:1460
10 ruby 0x10080a914 rb_autoload_str + 224 variable.c:2666
9 ruby 0x1007c3308 rb_mutex_synchronize + 56 thread_sync.c:637
8 ruby 0x1005acb24 rb_ensure + 312 eval.c:1009
7 ruby 0x10080aac8 autoload_synchronized + 204 variable.c:2630
6 ruby 0x10080f8bc autoload_feature_lookup_or_create + 76 variable.c:2578
5 ruby 0x1005c29a4 rb_data_typed_object_zalloc + 232 gc.c:3186
4 ruby 0x1005c2774 ruby_xcalloc + 32 gc.c:14440
3 ruby 0x1005cddf4 ruby_xcalloc_body + 56 gc.c:12878
2 ruby 0x1005cde7c objspace_xcalloc + 124 gc.c:12871
1 ruby 0x1005c1990 calloc1 + 28 gc.c:1906
0 libsystem_malloc.dylib 0x18b2ebb78 _malloc_zone_calloc_instrumented_or_legacy + 100
|
|
|
|
* Reword Range#overlap? docs last paragraph.
* Docs: add explanation about Queue#freeze
* Docs: Add :rescue event docs for TracePoint
* Docs: Enhance Module#set_temporary_name documentation
* Docs: Slightly expand Process::Status deprecations
* Fix MatchData#named_captures rendering glitch
* Improve Dir.fchdir examples
* Adjust Refinement#target docs
|
|
when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown.
Co-authored-by: Nobuyoshi Nakada <[email protected]>
Co-authored-by: Peter Zhu <[email protected]>
|
|
|
|
For this public API, the callback is declared to take
`(ID, VALUE, st_data_t)`, but it so happens that using
`(st_data_t, st_data_t, st_data_t)` also
type checks, because the underlying type is identical.
Use it as declared and get rid of some casts.
|
|
|
|
|
|
When generic instance variable has a shape, it is marked movable. If it
it transitions to too complex, it needs to update references otherwise
it may have incorrect references.
|
|
When evacuating generic instance variables, the instance variables exist
in both the array and the ST table. We need to ensure it has switched
to the ST table before performing any operations that can trigger GC
compaction.
|
|
We don't need to check for Qundef because the shape tells us the number
if IVs that are stored on the object
|
|
The lookup in the table is using the wrong key when converting generic
instance variables to too complex, which means that it never looks up
the entry which leaks memory when the entry is overwritten.
|
|
Too complex classes use a hash table to store ivs, and should always pin
their IVs. We shouldn't touch those classes in compaction.
|