summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-06-13 17:56:26 +0200
committerJean Boussier <[email protected]>2025-06-13 23:50:30 +0200
commit15084fbc3c10d21769dd61cd1cd55b2662fa8845 (patch)
tree9f1e0011f56a9bef9aeb3139969e9b1e5217e00f
parent6dbe24fe5641e5c86638ff5c5d9fe08ea31d196d (diff)
Get rid of FL_EXIVAR
Now that the shape_id gives us all the same information, it's no longer needed.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13612
-rw-r--r--bootstraptest/test_yjit.rb2
-rw-r--r--gc.c2
-rw-r--r--include/ruby/internal/fl_type.h35
-rw-r--r--misc/lldb_rb/commands/print_flags_command.py2
-rw-r--r--rubyparser.h2
-rw-r--r--shape.c7
-rw-r--r--string.c1
-rw-r--r--variable.c20
-rw-r--r--yjit/src/cruby_bindings.inc.rs3
-rw-r--r--zjit/src/cruby_bindings.inc.rs3
10 files changed, 29 insertions, 48 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 8d02998254..d480369c75 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -220,7 +220,7 @@ assert_equal 'Sub', %q{
call(Sub.new('o')).class
}
-# String#dup with FL_EXIVAR
+# String#dup with generic ivars
assert_equal '["str", "ivar"]', %q{
def str_dup(str) = str.dup
str = "str"
diff --git a/gc.c b/gc.c
index 9cb9dfce29..eacd8dae86 100644
--- a/gc.c
+++ b/gc.c
@@ -4010,8 +4010,6 @@ vm_weak_table_gen_fields_foreach(st_data_t key, st_data_t value, st_data_t data)
case ST_DELETE:
free_gen_fields_tbl((VALUE)key, (struct gen_fields_tbl *)value);
-
- FL_UNSET((VALUE)key, FL_EXIVAR);
RBASIC_SET_SHAPE_ID((VALUE)key, ROOT_SHAPE_ID);
return ST_DELETE;
diff --git a/include/ruby/internal/fl_type.h b/include/ruby/internal/fl_type.h
index 701118ef25..e52ccecedd 100644
--- a/include/ruby/internal/fl_type.h
+++ b/include/ruby/internal/fl_type.h
@@ -253,6 +253,21 @@ ruby_fl_type {
= 0,
/**
+ * @deprecated This flag was an implementation detail that should never have
+ * no been exposed. Exists here for backwards
+ * compatibility only. You can safely forget about it.
+ */
+ RUBY_FL_EXIVAR
+
+#if defined(RBIMPL_HAVE_ENUM_ATTRIBUTE)
+ RBIMPL_ATTR_DEPRECATED(("FL_EXIVAR is an outdated implementation detail, it shoudl be used."))
+#elif defined(_MSC_VER)
+# pragma deprecated(RUBY_FL_EXIVAR)
+#endif
+
+ = 0,
+
+ /**
* This flag has something to do with Ractor. Multiple Ractors run without
* protecting each other. Sharing an object among Ractors are basically
* dangerous, disabled by default. This flag is used to bypass that
@@ -286,18 +301,12 @@ ruby_fl_type {
*/
RUBY_FL_UNUSED9 = (1<<9),
- /**
- * This flag has something to do with instance variables. 3rd parties need
- * not know, but there are several ways to store an object's instance
- * variables. Objects with this flag use so-called "generic" backend
- * storage. This distinction is purely an implementation detail. People
- * need not be aware of this working behind-the-scene.
- *
- * @internal
- *
- * As of writing everything except ::RObject and RModule use this scheme.
- */
- RUBY_FL_EXIVAR = (1<<10),
+ /**
+ * This flag is no longer in use
+ *
+ * @internal
+ */
+ RUBY_FL_UNUSED10 = (1<<10),
/**
* This flag has something to do with data immutability. When this flag is
@@ -399,7 +408,7 @@ enum {
# pragma deprecated(RUBY_FL_DUPPED)
#endif
- = (int)RUBY_T_MASK | (int)RUBY_FL_EXIVAR
+ = (int)RUBY_T_MASK
};
#undef RBIMPL_HAVE_ENUM_ATTRIBUTE
diff --git a/misc/lldb_rb/commands/print_flags_command.py b/misc/lldb_rb/commands/print_flags_command.py
index 2b056dd098..bc494ae01a 100644
--- a/misc/lldb_rb/commands/print_flags_command.py
+++ b/misc/lldb_rb/commands/print_flags_command.py
@@ -17,7 +17,7 @@ class PrintFlagsCommand(RbBaseCommand):
flags = [
"RUBY_FL_WB_PROTECTED", "RUBY_FL_PROMOTED", "RUBY_FL_FINALIZE",
- "RUBY_FL_SHAREABLE", "RUBY_FL_EXIVAR", "RUBY_FL_FREEZE",
+ "RUBY_FL_SHAREABLE", "RUBY_FL_FREEZE",
"RUBY_FL_USER0", "RUBY_FL_USER1", "RUBY_FL_USER2", "RUBY_FL_USER3", "RUBY_FL_USER4",
"RUBY_FL_USER5", "RUBY_FL_USER6", "RUBY_FL_USER7", "RUBY_FL_USER8", "RUBY_FL_USER9",
"RUBY_FL_USER10", "RUBY_FL_USER11", "RUBY_FL_USER12", "RUBY_FL_USER13", "RUBY_FL_USER14",
diff --git a/rubyparser.h b/rubyparser.h
index 16f5cac81f..7525069fcb 100644
--- a/rubyparser.h
+++ b/rubyparser.h
@@ -1153,7 +1153,7 @@ typedef struct RNode_ERROR {
#define RNODE_FILE(node) ((rb_node_file_t *)(node))
#define RNODE_ENCODING(node) ((rb_node_encoding_t *)(node))
-/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED, 9: UNUSED, 10: EXIVAR, 11: FREEZE */
+/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8..10: UNUSED, 11: FREEZE */
/* NODE_FL: 0..4: UNUSED, 5: UNUSED, 6: UNUSED, 7: NODE_FL_NEWLINE,
* 8..14: nd_type,
* 15..: nd_line
diff --git a/shape.c b/shape.c
index 3e70589a6e..06dcb8d610 100644
--- a/shape.c
+++ b/shape.c
@@ -1266,13 +1266,6 @@ rb_shape_verify_consistency(VALUE obj, shape_id_t shape_id)
}
}
- if (FL_TEST_RAW(obj, FL_EXIVAR)) {
- RUBY_ASSERT(rb_obj_exivar_p(obj));
- }
- else {
- RUBY_ASSERT(!rb_obj_exivar_p(obj));
- }
-
return true;
}
#endif
diff --git a/string.c b/string.c
index 049e824437..d9ffb29b8e 100644
--- a/string.c
+++ b/string.c
@@ -485,7 +485,6 @@ build_fstring(VALUE str, struct fstr_update_arg *arg)
RUBY_ASSERT(RB_TYPE_P(str, T_STRING));
RUBY_ASSERT(OBJ_FROZEN(str));
RUBY_ASSERT(!FL_TEST_RAW(str, STR_FAKESTR));
- RUBY_ASSERT(!FL_TEST_RAW(str, FL_EXIVAR));
RUBY_ASSERT(!rb_obj_exivar_p(str));
RUBY_ASSERT(RBASIC_CLASS(str) == rb_cString);
RUBY_ASSERT(!rb_objspace_garbage_object_p(str));
diff --git a/variable.c b/variable.c
index f2561c0dfa..67dc2d3397 100644
--- a/variable.c
+++ b/variable.c
@@ -1271,7 +1271,6 @@ rb_free_generic_ivar(VALUE obj)
xfree(fields_tbl);
}
}
- FL_UNSET_RAW(obj, FL_EXIVAR);
RBASIC_SET_SHAPE_ID(obj, ROOT_SHAPE_ID);
}
}
@@ -1329,7 +1328,6 @@ rb_obj_field_get(VALUE obj, shape_id_t target_shape_id)
fields_hash = ROBJECT_FIELDS_HASH(obj);
break;
default:
- RUBY_ASSERT(FL_TEST_RAW(obj, FL_EXIVAR));
RUBY_ASSERT(rb_obj_exivar_p(obj));
struct gen_fields_tbl *fields_tbl = NULL;
rb_ivar_generic_fields_tbl_lookup(obj, &fields_tbl);
@@ -1361,7 +1359,6 @@ rb_obj_field_get(VALUE obj, shape_id_t target_shape_id)
fields = ROBJECT_FIELDS(obj);
break;
default:
- RUBY_ASSERT(FL_TEST_RAW(obj, FL_EXIVAR));
RUBY_ASSERT(rb_obj_exivar_p(obj));
struct gen_fields_tbl *fields_tbl = NULL;
rb_ivar_generic_fields_tbl_lookup(obj, &fields_tbl);
@@ -1839,9 +1836,6 @@ generic_fields_lookup_ensure_size(st_data_t *k, st_data_t *v, st_data_t u, int e
RUBY_ASSERT(RSHAPE_TYPE_P(fields_lookup->shape_id, SHAPE_IVAR) || RSHAPE_TYPE_P(fields_lookup->shape_id, SHAPE_OBJ_ID));
RUBY_ASSERT(RSHAPE_CAPACITY(RSHAPE_PARENT(fields_lookup->shape_id)) < RSHAPE_CAPACITY(fields_lookup->shape_id));
}
- else {
- FL_SET_RAW((VALUE)*k, FL_EXIVAR);
- }
fields_tbl = gen_fields_tbl_resize(fields_tbl, RSHAPE_CAPACITY(fields_lookup->shape_id));
*v = (st_data_t)fields_tbl;
@@ -1852,7 +1846,6 @@ generic_fields_lookup_ensure_size(st_data_t *k, st_data_t *v, st_data_t u, int e
rb_obj_set_shape_id(fields_lookup->obj, fields_lookup->shape_id);
}
- RUBY_ASSERT(FL_TEST((VALUE)*k, FL_EXIVAR));
RUBY_ASSERT(rb_obj_exivar_p((VALUE)*k));
return ST_CONTINUE;
@@ -1869,8 +1862,6 @@ generic_ivar_set_shape_fields(VALUE obj, void *data)
st_update(generic_fields_tbl(obj, fields_lookup->id, false), (st_data_t)obj, generic_fields_lookup_ensure_size, (st_data_t)fields_lookup);
}
- FL_SET_RAW(obj, FL_EXIVAR);
-
return fields_lookup->fields_tbl->as.shape.fields;
}
@@ -1893,7 +1884,6 @@ generic_ivar_set_set_shape_id(VALUE obj, shape_id_t shape_id, void *data)
static shape_id_t
generic_ivar_set_transition_too_complex(VALUE obj, void *_data)
{
- FL_SET_RAW(obj, FL_EXIVAR);
shape_id_t new_shape_id = rb_evict_fields_to_hash(obj);
return new_shape_id;
}
@@ -1911,8 +1901,6 @@ generic_ivar_set_too_complex_table(VALUE obj, void *data)
RB_VM_LOCKING() {
st_insert(generic_fields_tbl(obj, fields_lookup->id, false), (st_data_t)obj, (st_data_t)fields_tbl);
}
-
- FL_SET_RAW(obj, FL_EXIVAR);
}
RUBY_ASSERT(rb_shape_obj_too_complex_p(obj));
@@ -2368,8 +2356,6 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
if (gen_fields_tbl_count(obj, obj_fields_tbl) == 0)
goto clear;
- FL_SET(dest, FL_EXIVAR);
-
if (rb_shape_too_complex_p(src_shape_id)) {
rb_shape_copy_complex_ivars(dest, obj, src_shape_id, obj_fields_tbl->as.complex.table);
return;
@@ -2393,7 +2379,6 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
if (!RSHAPE_LEN(dest_shape_id)) {
rb_obj_set_shape_id(dest, dest_shape_id);
- FL_UNSET(dest, FL_EXIVAR);
return;
}
@@ -2424,15 +2409,10 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
void
rb_replace_generic_ivar(VALUE clone, VALUE obj)
{
- RUBY_ASSERT(FL_TEST(obj, FL_EXIVAR));
-
RB_VM_LOCKING() {
st_data_t fields_tbl, obj_data = (st_data_t)obj;
if (st_delete(generic_fields_tbl_, &obj_data, &fields_tbl)) {
- FL_UNSET_RAW(obj, FL_EXIVAR);
-
st_insert(generic_fields_tbl_, (st_data_t)clone, fields_tbl);
- FL_SET_RAW(clone, FL_EXIVAR);
}
else {
rb_bug("unreachable");
diff --git a/yjit/src/cruby_bindings.inc.rs b/yjit/src/cruby_bindings.inc.rs
index a1c7464805..1d7ffca165 100644
--- a/yjit/src/cruby_bindings.inc.rs
+++ b/yjit/src/cruby_bindings.inc.rs
@@ -225,10 +225,11 @@ pub const RUBY_FL_PROMOTED: ruby_fl_type = 32;
pub const RUBY_FL_UNUSED6: ruby_fl_type = 64;
pub const RUBY_FL_FINALIZE: ruby_fl_type = 128;
pub const RUBY_FL_TAINT: ruby_fl_type = 0;
+pub const RUBY_FL_EXIVAR: ruby_fl_type = 0;
pub const RUBY_FL_SHAREABLE: ruby_fl_type = 256;
pub const RUBY_FL_UNTRUSTED: ruby_fl_type = 0;
pub const RUBY_FL_UNUSED9: ruby_fl_type = 512;
-pub const RUBY_FL_EXIVAR: ruby_fl_type = 1024;
+pub const RUBY_FL_UNUSED10: ruby_fl_type = 1024;
pub const RUBY_FL_FREEZE: ruby_fl_type = 2048;
pub const RUBY_FL_USER0: ruby_fl_type = 4096;
pub const RUBY_FL_USER1: ruby_fl_type = 8192;
diff --git a/zjit/src/cruby_bindings.inc.rs b/zjit/src/cruby_bindings.inc.rs
index bcc8f48c37..5fb5c2ec02 100644
--- a/zjit/src/cruby_bindings.inc.rs
+++ b/zjit/src/cruby_bindings.inc.rs
@@ -101,10 +101,11 @@ pub const RUBY_FL_PROMOTED: ruby_fl_type = 32;
pub const RUBY_FL_UNUSED6: ruby_fl_type = 64;
pub const RUBY_FL_FINALIZE: ruby_fl_type = 128;
pub const RUBY_FL_TAINT: ruby_fl_type = 0;
+pub const RUBY_FL_EXIVAR: ruby_fl_type = 0;
pub const RUBY_FL_SHAREABLE: ruby_fl_type = 256;
pub const RUBY_FL_UNTRUSTED: ruby_fl_type = 0;
pub const RUBY_FL_UNUSED9: ruby_fl_type = 512;
-pub const RUBY_FL_EXIVAR: ruby_fl_type = 1024;
+pub const RUBY_FL_UNUSED10: ruby_fl_type = 1024;
pub const RUBY_FL_FREEZE: ruby_fl_type = 2048;
pub const RUBY_FL_USER0: ruby_fl_type = 4096;
pub const RUBY_FL_USER1: ruby_fl_type = 8192;