summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-30 22:03:42 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-30 22:03:42 +0000
commit198ff42258d9bfde8b2056d923510c52c957b5a1 (patch)
tree88b52dc706d767cd39f6bd26d00c33adf5cf0376 /gc.c
parent873d57347fca4fc7f407c2bca45f90797ab6f864 (diff)
support theap for T_STRUCT.
* struct.c: members memory can use theap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/gc.c b/gc.c
index 6f3b70cc70..d819e1b3a3 100644
--- a/gc.c
+++ b/gc.c
@@ -2383,14 +2383,17 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
break;
case T_STRUCT:
- if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) == 0 &&
- RANY(obj)->as.rstruct.as.heap.ptr) {
- xfree((void *)RANY(obj)->as.rstruct.as.heap.ptr);
- RB_DEBUG_COUNTER_INC(obj_struct_ptr);
- }
- else {
+ if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) ||
+ RANY(obj)->as.rstruct.as.heap.ptr == NULL) {
RB_DEBUG_COUNTER_INC(obj_struct_embed);
}
+ else if (RSTRUCT_TRANSIENT_P(obj)) {
+ RB_DEBUG_COUNTER_INC(obj_struct_transient);
+ }
+ else {
+ xfree((void *)RANY(obj)->as.rstruct.as.heap.ptr);
+ RB_DEBUG_COUNTER_INC(obj_struct_ptr);
+ }
break;
case T_SYMBOL:
@@ -4775,12 +4778,18 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
case T_STRUCT:
{
- long len = RSTRUCT_LEN(obj);
- const VALUE *ptr = RSTRUCT_CONST_PTR(obj);
+ long i;
+ const long len = RSTRUCT_LEN(obj);
+ const VALUE * const ptr = RSTRUCT_CONST_PTR(obj);
- while (len--) {
- gc_mark(objspace, *ptr++);
- }
+ for (i=0; i<len; i++) {
+ gc_mark(objspace, ptr[i]);
+ }
+
+ if (objspace->mark_func_data == NULL &&
+ RSTRUCT_TRANSIENT_P(obj)) {
+ rb_transient_heap_mark(obj, ptr);
+ }
}
break;