Commit graph

2250 commits

Author SHA1 Message Date
Aaron Patterson
08d5db4064
Reverting PR #4221
It seems this breaks tests on Solaris, so I'm reverting it until we
figure out the right fix.

  20210224T210007Z.fail.html.gz
2021-02-24 13:44:10 -08:00
Peter Zhu
a80366c922 Disable auto compaction on platforms that do not support it 2021-02-24 12:25:30 -08:00
Peter Zhu
785f5eb8f0 Use mmap for allocating heap pages 2021-02-24 12:25:30 -08:00
Koichi Sasada
d260cbe295 show more information about imemo_ment
rb_obj_info(obj) (rp(obj)) doesn't show enough information for
non-iseq methods, so this patch shows more.
2021-02-19 16:54:31 +09:00
Koichi Sasada
07ab172ebe sync check_rvalue_consistency_force()
check_rvalue_consistency_force() uses is_pointer_to_heap() and
it should be synchronized with other ractors.
[Bug #17636]
2021-02-18 17:04:59 +09:00
Koichi Sasada
100e464bee clear RVALUE on NEWOBJ event.
NEWOBJ event is called without clearing RVALUE values (v1, v2, v3).
This patch clear them before NEWOBJ tracepoint internal hook.
[Bug #17599]
2021-02-18 17:04:23 +09:00
Koichi Sasada
969b824a0c sync GC rest if needed
marking requires a barrier (stop all Ractors) and gc_enter() does it.
However, it doesn't check rest event which can start marking.
[Bug #17599]
2021-02-18 16:40:59 +09:00
Nobuyoshi Nakada
42a16e5974
Removed no-longer used variable 2021-02-17 20:15:05 +09:00
Peter Zhu
33b8bd97a8 Remove unreachable if statement in gc_page_sweep
This if statement is not reachable because `was_compacting` cannot be true when `heap->compact_cursor` is NULL.
2021-02-16 15:07:59 -08:00
Aaron Patterson
75b96c3a05 Don't register non-heap allocated objects
`rb_define_const` can add objects as "mark objects".  This is to make
code like this work:

  33d6e92e0c/ext/etc/etc.c (L1201)

```
    rb_define_const(rb_cStruct, "Passwd", sPasswd); /* deprecated name */
```

sPasswd is a heap allocated object that is also a C global, so we can't
move it (it needs to be pinned).  However, we have many calls to
`rb_define_const` that just pass in an integer like this:

```
rb_define_const(rb_cDBM, "WRITER",  INT2FIX(O_RDWR|RUBY_DBM_RW_BIT));
```

Non heap allocated objects like integers will never move, so there is no
reason to waste time in the GC marking / pinning them.
2021-02-04 09:49:00 -08:00
Matt Valentine-House
e3ef21c307 Use RCLASS_EXT macro instead of directly accessing ptr 2021-02-01 08:42:54 -08:00
Matt Valentine-House
e0f999a2ed Add RCLASS_SUBCLASSES Macro 2021-02-01 08:42:54 -08:00
Nobuyoshi Nakada
e44870c225
Removed static assertion about size of RVALUE
It is unable where unaligned word access is disallowed and
`double` is wider than pointers.
2021-01-31 17:45:35 +09:00
Nobuyoshi Nakada
ae0a179c4b
Narrowed down the condition to pack RValue
Because of `double` in `RFloat`, `RValue` would be packed by
`sizeof(double)` by default, on platforms where `double` is wider
than `VALUE`.  Size of `RValue` is multiple of 5 now.
2021-01-31 13:20:15 +09:00
Peter Zhu
d2ffd269a7 [Fixes #17538] Fix assertion failure when rincgc is turned off
Co-Authored-By: Matt Valentine-House <31869+eightbitraptor@users.noreply.github.com>
2021-01-27 16:17:46 -08:00
Matt Valentine-House
8a3f816675 Re-enable RGENGC_DEBUG for platforms with HAVE_VA_ARGS_MACRO
after this commit turned it off globally.

888cf28a7e

Co-authored-by: peterzhu2118 <peter@peterzhu.ca>
2021-01-26 08:18:44 -08:00
Matt Valentine-House
479e4d13cb Fix RGENGC CHECK MODE >= 4
[A previous commit](b59077eecf912a16efefc0256f6e94a000ce3888) removes some macro definitions that are used when RGENGC_CHECK_MODE >=4 because they were using data stored against objspace, which is not ractor safe

This commit reinstates those macro definitions, using the current ractor

Co-authored-by: peterzhu2118 <peter@peterzhu.ca>
2021-01-26 08:17:58 -08:00
Yusuke Endoh
47d6c55755 gc.c: stop overflow check on emscripten build 2021-01-23 10:11:50 +09:00
Koichi Sasada
e586345b77 check is_incremental_marking() again
is_incremental_marking() can be changed after checking the
flag without locking, especially on `GC.stress = true`.
2021-01-22 18:15:57 +09:00
Aaron Patterson
32b7dcfb56
Fix more assumptions about the read barrier
This is a continuation of 0130e17a41.  We
need to always use the read barrier
2021-01-21 11:19:44 -08:00
Aaron Patterson
0130e17a41
Always enabled read barrier even on GC.compact
Some objects can survive the GC before compaction, but get collected in
the second compaction.  This means we could have objects reference
T_MOVED during "free" in the second, compacting GC.  If that is the
case, we need to invalidate those "moved" addresses.  Invalidation is
done via read barrier, so we need to make sure the read barrier is
active even during `GC.compact`.

This also means we don't actually need to do one GC before compaction,
we can just do the compaction and GC in one step.
2021-01-21 09:55:18 -08:00
Aaron Patterson
589a8026f0 fix ASAN errors 2021-01-13 14:53:45 -08:00
David CARLIER
161a20df28 gc fix typo for the timer instruction for ARM64. 2021-01-09 22:37:27 +09:00
Koichi Sasada
442bd0e92c show more info about imemo_callcache 2021-01-06 14:57:48 +09:00
Marcus Stollsteimer
3108ad7bf3 [DOC] Fix grammar: "is same as" -> "is the same as" 2021-01-05 15:13:53 +01:00
Koichi Sasada
e7fc353f04 enable constant cache on ractors
constant cache `IC` is accessed by non-atomic manner and there are
thread-safety issues, so Ruby 3.0 disables to use const cache on
non-main ractors.

This patch enables it by introducing `imemo_constcache` and allocates
it by every re-fill of const cache like `imemo_callcache`.
[Bug #17510]

Now `IC` only has one entry `IC::entry` and it points to
`iseq_inline_constant_cache_entry`, managed by T_IMEMO object.

`IC` is atomic data structure so `rb_mjit_before_vm_ic_update()` and
`rb_mjit_after_vm_ic_update()` is not needed.
2021-01-05 02:27:58 +09:00
Takashi Kokubun
ac2df89113
Stop managing valid class serials
`mjit_valid_class_serial_p` has no longer been used since b9007b6c54.
2020-12-29 23:01:11 -08:00
Nobuyoshi Nakada
09aca50fc4
Adjusted styles [ci skip] 2020-12-28 19:52:14 +09:00
Nobuyoshi Nakada
292230cbf9 Fixed leaked global symbols 2020-12-26 09:39:53 +09:00
Koichi Sasada
888cf28a7e define RGENGC_DEBUG_ENABLED() as 0
on RUBY_DEVEL==0 and !HAVE_VA_ARGS_MACRO.

gc_report() is always enabled on such configuration
(maybe it is a bug) so disable RGENGC_DEBUG_ENABLED().
2020-12-25 11:20:23 +09:00
Nobuyoshi Nakada
313d63c2ac
Use rb_init_identtable instead of direct use of rb_hashtype_ident 2020-12-23 18:06:27 +09:00
Koichi Sasada
02d9524cda separate rb_ractor_pub from rb_ractor_t
separate some fields from rb_ractor_t to rb_ractor_pub and put it
at the beggining of rb_ractor_t and declare it in vm_core.h so
vm_core.h can access rb_ractor_pub fields.

Now rb_ec_ractor_hooks() is a complete inline function and no
MJIT related issue.
2020-12-22 00:03:00 +09:00
Koichi Sasada
74ab2c3b46 finalizing should be checked before VM lock 2020-12-18 17:59:26 +09:00
Nobuyoshi Nakada
7d32bf7853
Removed a moved local variable 2020-12-18 17:56:08 +09:00
Koichi Sasada
61236770e6 need to sync gc_finalize_deferred
gc_finalize_deferred() runs finalizers and it accesses objspace,
so it need to sync.
2020-12-18 17:50:01 +09:00
Nobuyoshi Nakada
75416b8628 Removed old GC.stat keys deprecated since 2.2 2020-12-18 16:27:43 +09:00
Nobuyoshi Nakada
763d5f9c6b Removed old GC tuning environment variables deprecated since 2.1 2020-12-18 16:27:43 +09:00
Koichi Sasada
cfa124ef05 acquire VM lock on gc_verify_internal_consistency()
There is a case to call this function without VM lock acquiring.
2020-12-18 14:16:06 +09:00
Koichi Sasada
29e42b8bfd add explicit check
To debug this issue:
20201217T220004Z.fail.html.gz
2020-12-18 08:26:25 +09:00
Koichi Sasada
6538c89f1c gc_verify_internal_consistency() needs barrier
gc_verify_internal_consistency() accesses all slots (objects) so
all ractors should stop before starting this function.
2020-12-18 01:20:02 +09:00
Koichi Sasada
da3438a504 sync obj_to_id_tbl
objspace->obj_to_id_tbl is a shared table so we need to synchronize
it to access.
2020-12-17 18:13:40 +09:00
Koichi Sasada
7f11c8086a reduce barrier counts for GC events
mark needs barrier (stop other ractors), but other GC events don't need
barriers (maybe...).
2020-12-17 18:13:26 +09:00
Koichi Sasada
99b9145380 relax synchronization on WB
Current synchronization is too much on write barriers.
2020-12-17 17:37:52 +09:00
Koichi Sasada
c42948d784 add debug counters for gc start events 2020-12-17 17:03:05 +09:00
Koichi Sasada
93ba3ac036 RGENGC_PROFILE=0
Enabled this flag, maybe accidentally.
2020-12-17 03:46:44 +09:00
Nobuyoshi Nakada
289d42c932
Removed unneeded cast and use the real name 2020-12-15 23:43:08 +09:00
Koichi Sasada
974e89ae07 revert da3bca513f
It seems introduce critical problems. Now I could not find
out the issue.

http://ci.rvm.jp/results/trunk-test@ruby-sky1/3286048
2020-12-11 09:54:34 +09:00
Koichi Sasada
72f1c43584 ObjectSpace._id2ref should not support unshareable
ObjectSpace._id2ref(id) can return any objects even if they are
unshareable, so this patch raises RangeError if it runs on multi-ractor
mode and the found object is unshareable.
2020-12-10 18:27:44 +09:00
Nobuyoshi Nakada
142f154a0a
Unpoison freelist to chain 2020-12-10 18:16:22 +09:00
Koichi Sasada
da3bca513f cache free pages per ractor
Per ractor method cache (GH-#3842) only cached 1 page and this patch
caches several pages to keep at least 512 free slots if available.
If you increase the number of cached free slots, all cached slots
will be collected when the GC is invoked.
2020-12-10 13:05:43 +09:00