summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--class.c2
-rw-r--r--gc.c21
-rw-r--r--include/ruby/ruby.h3
-rw-r--r--iseq.c2
5 files changed, 38 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a16118..ac6f3a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Thu Dec 11 19:06:01 2014 Koichi Sasada <ko1@atdot.net>
+
+ * class.c (class_alloc): Strat from age == 2.
+ Class and Module objects can be living long life.
+
+ * iseq.c: Same for ISeq objects.
+
+ * gc.c (RVALUE_AGE_RESET): added.
+
+ * gc.c (newobj_of): allow to generate (age != 0) objects.
+
+ * gc.c (rb_copy_wb_protected_attribute): reset age for wb unprotected
+ objects.
+
+ * include/ruby/ruby.h: add RUBY_TYPED_PROMOTED1 as an unrecommended
+ flag.
+
Thu Dec 11 05:37:52 2014 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/prime.rb: Remove useless loop and block capture.
diff --git a/class.c b/class.c
index 06a12a4..9868b72 100644
--- a/class.c
+++ b/class.c
@@ -150,7 +150,7 @@ rb_class_detach_module_subclasses(VALUE klass)
static VALUE
class_alloc(VALUE flags, VALUE klass)
{
- NEWOBJ_OF(obj, struct RClass, klass, (flags & T_MASK) | (RGENGC_WB_PROTECTED_CLASS ? FL_WB_PROTECTED : 0));
+ NEWOBJ_OF(obj, struct RClass, klass, (flags & T_MASK) | FL_PROMOTED1 /* start from age == 2 */ | (RGENGC_WB_PROTECTED_CLASS ? FL_WB_PROTECTED : 0));
obj->ptr = ALLOC(rb_classext_t);
RCLASS_IV_TBL(obj) = 0;
RCLASS_CONST_TBL(obj) = 0;
diff --git a/gc.c b/gc.c
index 6c693fa..b215dac 100644
--- a/gc.c
+++ b/gc.c
@@ -1152,13 +1152,17 @@ RVALUE_DEMOTE(rb_objspace_t *objspace, VALUE obj)
}
static inline void
+RVALUE_AGE_RESET_RAW(VALUE obj)
+{
+ RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, 0);
+}
+
+static inline void
RVALUE_AGE_RESET(VALUE obj)
{
check_rvalue_consistency(obj);
if (RGENGC_CHECK_MODE) assert(!RVALUE_OLD_P(obj));
-
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, 0);
-
+ RVALUE_AGE_RESET_RAW(obj);
check_rvalue_consistency(obj);
}
@@ -1653,7 +1657,13 @@ newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3)
assert(RVALUE_MARKING(obj) == FALSE);
assert(RVALUE_OLD_P(obj) == FALSE);
assert(RVALUE_WB_UNPROTECTED(obj) == FALSE);
- if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj));
+
+ if (flags & FL_PROMOTED1) {
+ if (RVALUE_AGE(obj) != 2) rb_bug("newobj: %s of age (%d) != 2.", obj_info(obj), RVALUE_AGE(obj));
+ }
+ else {
+ if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj));
+ }
if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj));
#endif
@@ -5556,7 +5566,10 @@ rb_copy_wb_protected_attribute(VALUE dest, VALUE obj)
#if USE_RGENGC
if (RVALUE_WB_UNPROTECTED(obj)) {
MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(dest), dest);
+ RVALUE_AGE_RESET_RAW(dest);
}
+
+ check_rvalue_consistency(dest);
#endif
}
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 884042a..6f00037 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1019,7 +1019,8 @@ void *rb_check_typeddata(VALUE, const rb_data_type_t *);
/* bits for rb_data_type_struct::flags */
#define RUBY_TYPED_FREE_IMMEDIATELY 1 /* TYPE field */
-#define RUBY_TYPED_WB_PROTECTED FL_WB_PROTECTED
+#define RUBY_TYPED_WB_PROTECTED FL_WB_PROTECTED /* THIS FLAG DEPENDS ON Ruby version */
+#define RUBY_TYPED_PROMOTED1 FL_PROMOTED1 /* THIS FLAG DEPENDS ON Ruby version */
#define Data_Wrap_Struct(klass,mark,free,sval)\
rb_data_object_alloc((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
diff --git a/iseq.c b/iseq.c
index 742083f..1338981 100644
--- a/iseq.c
+++ b/iseq.c
@@ -182,7 +182,7 @@ static const rb_data_type_t iseq_data_type = {
iseq_memsize,
}, /* functions */
0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_PROMOTED1 /* start from age == 2 */ | RUBY_TYPED_WB_PROTECTED
};
static VALUE