Files
Koichi SasadaandClaude Opus 5 09aab7899f Ractor: derive object belonging from the owning objspace
RACTOR_CHECK_MODE stamped every object with the id of the Ractor that
allocated it (a 4 byte suffix on every slot), and re-stamped whole object
graphs whenever a value crossed a Ractor boundary.  Per-Ractor objspaces
already record the owner: an object's page knows its objspace, so
rb_gc_obj_foreign_p() answers "is this another Ractor's object" with one
load, and the id, its suffix and the re-stamping traversals all go away.

Deriving it is also more accurate.  The stamped id was never rewritten
when a zombie objspace was absorbed, which is what ractor_reset_belonging()
had to paper over by re-stamping received and inherited values.  Page
ownership moves with the absorb, so nothing is left stale.

thread.c stamped the child's main Thread wrapper with the child's id
because upstream allocates that wrapper in the parent's objspace.  This
branch already allocates it in the child's objspace, so the site goes too.

With ractor_reset_belonging() gone, no rb_obj_traverse() caller has an
enter function that descends into arbitrary types: make_shareable raises
on T_FILE and shareable_p stops there, so obj_traverse_i() can no longer
reach T_FILE and its case goes as well.

GC impls that keep a single objspace (mmtk) cannot tell owners apart and
report every object as their own, so the check degrades to a no-op there;
in exchange, dropping the suffix re-enables mmtk's ZJIT allocation
fastpath.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 16:27:53 +09:00

10 lines
240 B
C

#ifndef INTERNAL_RACTOR_H /*-*-C-*-vi:se ft=c:*/
#define INTERNAL_RACTOR_H
void rb_ractor_ensure_main_ractor(const char *msg);
RUBY_SYMBOL_EXPORT_BEGIN
RUBY_SYMBOL_EXPORT_END
#endif /* INTERNAL_RACTOR_H */