ruby-changes:40267
From: nobu <ko1@a...>
Date: Thu, 29 Oct 2015 17:00:20 +0900 (JST)
Subject: [ruby-changes:40267] nobu:r52348 (trunk): gc.c: separate event hook call from newobj_init
nobu 2015-10-29 17:00:01 +0900 (Thu, 29 Oct 2015) New Revision: 52348 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52348 Log: gc.c: separate event hook call from newobj_init * gc.c (newobj_init): separate event hook call and remove the argument for it. * gc.c (newobj_slowpath): call event hook after initialized the new object. Modified files: trunk/gc.c Index: gc.c =================================================================== --- gc.c (revision 52347) +++ gc.c (revision 52348) @@ -1705,7 +1705,7 @@ gc_event_hook_body(rb_thread_t *th, rb_o https://github.com/ruby/ruby/blob/trunk/gc.c#L1705 } while (0) static inline VALUE -newobj_init(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected, rb_objspace_t *objspace, VALUE obj, int hook_needed) +newobj_init(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected, rb_objspace_t *objspace, VALUE obj) { if (RGENGC_CHECK_MODE > 0) { assert(BUILTIN_TYPE(obj) == T_NONE); @@ -1763,9 +1763,6 @@ newobj_init(VALUE klass, VALUE flags, VA https://github.com/ruby/ruby/blob/trunk/gc.c#L1763 objspace->total_allocated_objects++; - if (UNLIKELY(hook_needed)) { - gc_event_hook(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj); - } gc_report(5, objspace, "newobj: %s\n", obj_info(obj)); #if RGENGC_OLD_NEWOBJ_CHECK > 0 @@ -1812,7 +1809,9 @@ newobj_slowpath(VALUE klass, VALUE flags https://github.com/ruby/ruby/blob/trunk/gc.c#L1809 } obj = heap_get_freeobj(objspace, heap_eden); - return newobj_init(klass, flags, v1, v2, v3, wb_protected, objspace, obj, gc_event_hook_needed_p(objspace, RUBY_INTERNAL_EVENT_NEWOBJ)); + newobj_init(klass, flags, v1, v2, v3, wb_protected, objspace, obj); + gc_event_hook(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj); + return obj; } static inline VALUE @@ -1834,7 +1833,7 @@ newobj_of(VALUE klass, VALUE flags, VALU https://github.com/ruby/ruby/blob/trunk/gc.c#L1833 ruby_gc_stressful || gc_event_hook_available_p(objspace)) && (obj = heap_get_freeobj_head(objspace, heap_eden)) != Qfalse)) { - return newobj_init(klass, flags, v1, v2, v3, wb_protected, objspace, obj, FALSE); + return newobj_init(klass, flags, v1, v2, v3, wb_protected, objspace, obj); } else { return newobj_slowpath(klass, flags, v1, v2, v3, wb_protected, objspace); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/