From 873d57347fca4fc7f407c2bca45f90797ab6f864 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 30 Oct 2018 22:01:17 +0000 Subject: support theap for T_OBJECT. * variable.c: now instance variable space has theap supports. obj_ivar_heap_alloc() tries to acquire memory from theap. * debug_counter.h: add some counters for theap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- transient_heap.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'transient_heap.c') diff --git a/transient_heap.c b/transient_heap.c index e9a2460d88..c1d8dbc97d 100644 --- a/transient_heap.c +++ b/transient_heap.c @@ -353,7 +353,8 @@ rb_transient_heap_alloc(VALUE obj, size_t req_size) struct transient_heap* theap = transient_heap_get(); size_t size = ROUND_UP(req_size + sizeof(struct transient_alloc_header), TRANSIENT_HEAP_ALLOC_ALIGN); - TH_ASSERT(RB_TYPE_P(obj, T_ARRAY)); /* supported types */ + TH_ASSERT(RB_TYPE_P(obj, T_ARRAY) || + RB_TYPE_P(obj, T_OBJECT)); /* 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)); @@ -557,6 +558,14 @@ transient_heap_ptr(VALUE obj, int error) ptr = NULL; } break; + case T_OBJECT: + if (ROBJ_TRANSIENT_P(obj)) { + ptr = ROBJECT_IVPTR(obj); + } + else { + ptr = NULL; + } + break; default: if (error) { rb_bug("transient_heap_ptr: unknown obj %s\n", rb_obj_info(obj)); @@ -659,11 +668,10 @@ transient_heap_block_evacuate(struct transient_heap* theap, struct transient_hea switch (BUILTIN_TYPE(obj)) { case T_ARRAY: -#if TRANSIENT_HEAP_DEBUG_DONT_PROMOTE - rb_ary_transient_heap_evacuate(obj, FALSE); -#else - rb_ary_transient_heap_evacuate(obj, TRUE); -#endif + rb_ary_transient_heap_evacuate(obj, !TRANSIENT_HEAP_DEBUG_DONT_PROMOTE); + break; + case T_OBJECT: + rb_obj_transient_heap_evacuate(obj, !TRANSIENT_HEAP_DEBUG_DONT_PROMOTE); break; default: rb_bug("unsupporeted"); -- cgit v1.2.1