diff options
author | Jean Boussier <[email protected]> | 2025-05-22 14:01:46 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-06-12 07:58:16 +0200 |
commit | 3abdd4241fd5231a5711ce1b087d660c667ef30d () | |
tree | ddcdd184ca6720bac671cf296a5b7474a22477f5 /shape.h | |
parent | 166ff187bd2a84fddd7a633bdbdbcd4ae393c91e (diff) |
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.
Notes: Merged: https://.com/ruby/ruby/pull/13411
-rw-r--r-- | shape.h | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -113,7 +113,7 @@ static inline shape_id_t RBASIC_SHAPE_ID(VALUE obj) { RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj)); - RUBY_ASSERT(!RB_TYPE_P(obj, T_IMEMO)); #if RBASIC_SHAPE_ID_FIELD return (shape_id_t)((RBASIC(obj)->shape_id)); #else @@ -137,8 +137,9 @@ static inline void RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id) { RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj)); - RUBY_ASSERT(!RB_TYPE_P(obj, T_IMEMO)); RUBY_ASSERT(rb_shape_verify_consistency(obj, shape_id)); #if RBASIC_SHAPE_ID_FIELD RBASIC(obj)->shape_id = (VALUE)shape_id; #else |