dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH] variable.c: remove generic ivar support for special constants
@ 2015-06-02  3:04 Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-06-02  3:04 UTC (permalink / raw)
  To: spew

Special constants are all frozen since [Feature #8923] and cannot
support ivars.  Remove some unused code we had for supporting them.
---
 gc.c       |  4 ----
 internal.h |  1 -
 variable.c | 22 ++--------------------
 3 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/gc.c b/gc.c
index eb0a073..5ce7a8f 100644
--- a/gc.c
+++ b/gc.c
@@ -4596,10 +4596,6 @@ gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
     MARK_CHECKPOINT("global_tbl");
     rb_gc_mark_global_tbl();
 
-    /* mark generic instance variables for special constants */
-    MARK_CHECKPOINT("generic_ivars");
-    rb_mark_generic_ivar_tbl();
-
     MARK_CHECKPOINT("live_method_entries");
     rb_gc_mark_unlinked_live_method_entries(th->vm);
 
diff --git a/internal.h b/internal.h
index 64896e0..9a6940b 100644
--- a/internal.h
+++ b/internal.h
@@ -1281,7 +1281,6 @@ extern unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, si
 /* variable.c (export) */
 void rb_gc_mark_global_tbl(void);
 void rb_mark_generic_ivar(VALUE);
-void rb_mark_generic_ivar_tbl(void);
 VALUE rb_const_missing(VALUE klass, VALUE name);
 
 int rb_st_insert_id_and_value(VALUE obj, st_table *tbl, ID key, VALUE value);
diff --git a/variable.c b/variable.c
index a5f6579..33583a0 100644
--- a/variable.c
+++ b/variable.c
@@ -25,7 +25,6 @@ static void setup_const_entry(rb_const_entry_t *, VALUE, VALUE, rb_const_flag_t)
 static int const_update(st_data_t *, st_data_t *, st_data_t, int);
 static st_table *generic_iv_tbl;
 static st_table *generic_iv_tbl_compat;
-static int special_generic_ivar;
 
 /* per-object */
 struct gen_ivtbl {
@@ -1182,23 +1181,6 @@ rb_mark_generic_ivar(VALUE obj)
     }
 }
 
-static int
-givar_i(st_data_t k, st_data_t v, st_data_t a)
-{
-    VALUE obj = (VALUE)k;
-    if (rb_special_const_p(obj)) {
-	gen_ivtbl_mark((const struct gen_ivtbl *)v);
-    }
-    return ST_CONTINUE;
-}
-
-void
-rb_mark_generic_ivar_tbl(void)
-{
-    if (special_generic_ivar == 0) return;
-    st_foreach_safe(generic_iv_tbl, givar_i, 0);
-}
-
 void
 rb_free_generic_ivar(VALUE obj)
 {
@@ -1371,7 +1353,7 @@ generic_ivar_set(VALUE obj, ID id, VALUE val)
 
     if (rb_special_const_p(obj)) {
 	if (rb_obj_frozen_p(obj)) rb_error_frozen("object");
-	special_generic_ivar = 1;
+        rb_bug("non-frozen special constant");
     }
 
     ivup.extended = 0;
@@ -1579,7 +1561,7 @@ rb_copy_generic_ivar(VALUE clone, VALUE obj)
 
     if (rb_special_const_p(clone)) {
 	if (rb_obj_frozen_p(clone)) rb_error_frozen("object");
-	special_generic_ivar = 1;
+        rb_bug("non-frozen special constant");
     }
 
     if (!FL_TEST(obj, FL_EXIVAR)) {
-- 
EW


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] variable.c: remove generic ivar support for special constants
@ 2015-06-02  3:05 Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-06-02  3:05 UTC (permalink / raw)
  To: spew

Special constants are all frozen since [Feature #8923] and cannot
support ivars.  Remove some unused code we had for supporting them.
---
 gc.c       |  4 ----
 internal.h |  1 -
 variable.c | 22 ++--------------------
 3 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/gc.c b/gc.c
index eb0a073..5ce7a8f 100644
--- a/gc.c
+++ b/gc.c
@@ -4596,10 +4596,6 @@ gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
     MARK_CHECKPOINT("global_tbl");
     rb_gc_mark_global_tbl();
 
-    /* mark generic instance variables for special constants */
-    MARK_CHECKPOINT("generic_ivars");
-    rb_mark_generic_ivar_tbl();
-
     MARK_CHECKPOINT("live_method_entries");
     rb_gc_mark_unlinked_live_method_entries(th->vm);
 
diff --git a/internal.h b/internal.h
index 64896e0..9a6940b 100644
--- a/internal.h
+++ b/internal.h
@@ -1281,7 +1281,6 @@ extern unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, si
 /* variable.c (export) */
 void rb_gc_mark_global_tbl(void);
 void rb_mark_generic_ivar(VALUE);
-void rb_mark_generic_ivar_tbl(void);
 VALUE rb_const_missing(VALUE klass, VALUE name);
 
 int rb_st_insert_id_and_value(VALUE obj, st_table *tbl, ID key, VALUE value);
diff --git a/variable.c b/variable.c
index a5f6579..827ceb7 100644
--- a/variable.c
+++ b/variable.c
@@ -25,7 +25,6 @@ static void setup_const_entry(rb_const_entry_t *, VALUE, VALUE, rb_const_flag_t)
 static int const_update(st_data_t *, st_data_t *, st_data_t, int);
 static st_table *generic_iv_tbl;
 static st_table *generic_iv_tbl_compat;
-static int special_generic_ivar;
 
 /* per-object */
 struct gen_ivtbl {
@@ -1182,23 +1181,6 @@ rb_mark_generic_ivar(VALUE obj)
     }
 }
 
-static int
-givar_i(st_data_t k, st_data_t v, st_data_t a)
-{
-    VALUE obj = (VALUE)k;
-    if (rb_special_const_p(obj)) {
-	gen_ivtbl_mark((const struct gen_ivtbl *)v);
-    }
-    return ST_CONTINUE;
-}
-
-void
-rb_mark_generic_ivar_tbl(void)
-{
-    if (special_generic_ivar == 0) return;
-    st_foreach_safe(generic_iv_tbl, givar_i, 0);
-}
-
 void
 rb_free_generic_ivar(VALUE obj)
 {
@@ -1371,7 +1353,7 @@ generic_ivar_set(VALUE obj, ID id, VALUE val)
 
     if (rb_special_const_p(obj)) {
 	if (rb_obj_frozen_p(obj)) rb_error_frozen("object");
-	special_generic_ivar = 1;
+	rb_bug("non-frozen special constant");
     }
 
     ivup.extended = 0;
@@ -1579,7 +1561,7 @@ rb_copy_generic_ivar(VALUE clone, VALUE obj)
 
     if (rb_special_const_p(clone)) {
 	if (rb_obj_frozen_p(clone)) rb_error_frozen("object");
-	special_generic_ivar = 1;
+	rb_bug("non-frozen special constant");
     }
 
     if (!FL_TEST(obj, FL_EXIVAR)) {
-- 
EW


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-02  3:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-02  3:04 [PATCH] variable.c: remove generic ivar support for special constants Eric Wong
  -- strict thread matches above, loose matches on Subject: below --
2015-06-02  3:05 Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).