From 198ff42258d9bfde8b2056d923510c52c957b5a1 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 30 Oct 2018 22:03:42 +0000 Subject: 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 --- transient_heap.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'transient_heap.c') diff --git a/transient_heap.c b/transient_heap.c index c1d8dbc97d..5f9962f4a0 100644 --- a/transient_heap.c +++ b/transient_heap.c @@ -354,7 +354,8 @@ rb_transient_heap_alloc(VALUE obj, size_t req_size) size_t size = ROUND_UP(req_size + sizeof(struct transient_alloc_header), TRANSIENT_HEAP_ALLOC_ALIGN); TH_ASSERT(RB_TYPE_P(obj, T_ARRAY) || - RB_TYPE_P(obj, T_OBJECT)); /* supported types */ + RB_TYPE_P(obj, T_OBJECT) || + RB_TYPE_P(obj, T_STRUCT)); /* supported types */ if (size > TRANSIENT_HEAP_ALLOC_MAX) { if (TRANSIENT_HEAP_DEBUG >= 3) fprintf(stderr, "rb_transient_heap_alloc: [too big: %ld] %s\n", (long)size, rb_obj_info(obj)); @@ -546,7 +547,7 @@ rb_transient_heap_mark(VALUE obj, const void *ptr) static const void * transient_heap_ptr(VALUE obj, int error) { - const void *ptr; + const void *ptr = NULL; switch (BUILTIN_TYPE(obj)) { case T_ARRAY: @@ -554,25 +555,21 @@ transient_heap_ptr(VALUE obj, int error) TH_ASSERT(!FL_TEST_RAW(obj, RARRAY_EMBED_FLAG)); ptr = RARRAY(obj)->as.heap.ptr; } - else { - ptr = NULL; - } break; case T_OBJECT: if (ROBJ_TRANSIENT_P(obj)) { ptr = ROBJECT_IVPTR(obj); } - else { - ptr = NULL; + break; + case T_STRUCT: + if (RSTRUCT_TRANSIENT_P(obj)) { + ptr = rb_struct_const_heap_ptr(obj); } break; default: if (error) { rb_bug("transient_heap_ptr: unknown obj %s\n", rb_obj_info(obj)); } - else { - ptr = NULL; - } } return ptr; @@ -673,6 +670,9 @@ transient_heap_block_evacuate(struct transient_heap* theap, struct transient_hea case T_OBJECT: rb_obj_transient_heap_evacuate(obj, !TRANSIENT_HEAP_DEBUG_DONT_PROMOTE); break; + case T_STRUCT: + rb_struct_transient_heap_evacuate(obj, !TRANSIENT_HEAP_DEBUG_DONT_PROMOTE); + break; default: rb_bug("unsupporeted"); } -- cgit v1.2.3