Turn rb_classext_t.fields into a T_IMEMO/class_fields

This behave almost exactly as a T_OBJECT, the layout is entirely
compatible.

This aims to solve two problems.

First, it solves the problem of namspaced classes having
a single `shape_id`. Now each namespaced classext
has an object that can hold the namespace specific
shape.

Second, it open the door to later make class instance variable
writes atomics, hence be able to read class variables
without locking the VM.
In the future, in multi-ractor mode, we can do the write
on a copy of the `fields_obj` and then atomically swap it.

Considerations:

  - Right now the `RClass` shape_id is always synchronized,
    but with namespace we should likely mark classes that have
    multiple namespace with a specific shape flag.
This commit is contained in:
Jean Boussier 2025-05-22 14:01:46 +02:00
parent 166ff187bd
commit 3abdd4241f
Notes: git 2025-06-12 05:58:29 +00:00
14 changed files with 435 additions and 218 deletions

View file

@ -409,6 +409,7 @@ pub const imemo_parser_strterm: imemo_type = 10;
pub const imemo_callinfo: imemo_type = 11;
pub const imemo_callcache: imemo_type = 12;
pub const imemo_constcache: imemo_type = 13;
pub const imemo_class_fields: imemo_type = 14;
pub type imemo_type = u32;
#[repr(C)]
#[derive(Debug, Copy, Clone)]