diff options
author | tmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-05 04:26:04 +0000 |
---|---|---|
committer | tmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-05 04:26:04 +0000 |
commit | 393b9e65e91036743609e0d5ed899072b0f2d0a8 (patch) | |
tree | 0d8d8c358b852e73e3f9dcd9eeefb057c4cd36bc | |
parent | fb29aefc7abe3fe1b2c7794035a73f9ba50e8364 (diff) | |
download | ruby-393b9e65e91036743609e0d5ed899072b0f2d0a8.tar.gz |
gc.c: split GC_END event into GC_END_MARK and GC_END_SWEEP
* include/ruby/ruby.h: remove INTERNAL_EVENT_GC_END and replace with
two new events: GC_END_MARK and GC_END_SWEEP
* gc.c (gc_after_sweep): emit GC_END_SWEEP after lazy sweep is done
* gc.c (gc_marks_body): emit GC_END_MARK at end of minor/major mark
* ext/-test-/tracepoint/tracepoint.c (struct tracepoint_track): tests
for new events.
* test/-ext-/tracepoint/test_tracepoint.rb (class TestTracepointObj):
ditto.
* NEWS: remove ObjectSpace.after_gc_*_hook. These are only a sample,
and will be removed before ruby 2.1.
* ext/objspace/gc_hook.c: remove ObjectSpace.after_gc_end_hook=
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/-test-/tracepoint/tracepoint.c | 18 | ||||
-rw-r--r-- | ext/objspace/gc_hook.c | 8 | ||||
-rw-r--r-- | gc.c | 4 | ||||
-rw-r--r-- | include/ruby/ruby.h | 19 | ||||
-rw-r--r-- | test/-ext-/tracepoint/test_tracepoint.rb | 12 |
7 files changed, 46 insertions, 31 deletions
@@ -1,3 +1,17 @@ +Thu Dec 5 13:19:03 2013 Aman Gupta <ruby@tmm1.net> + + * include/ruby/ruby.h: remove INTERNAL_EVENT_GC_END and replace with + two new events: GC_END_MARK and GC_END_SWEEP + * gc.c (gc_after_sweep): emit GC_END_SWEEP after lazy sweep is done + * gc.c (gc_marks_body): emit GC_END_MARK at end of minor/major mark + * ext/-test-/tracepoint/tracepoint.c (struct tracepoint_track): tests + for new events. + * test/-ext-/tracepoint/test_tracepoint.rb (class TestTracepointObj): + ditto. + * NEWS: remove ObjectSpace.after_gc_*_hook. These are only a sample, + and will be removed before ruby 2.1. + * ext/objspace/gc_hook.c: remove ObjectSpace.after_gc_end_hook= + Thu Dec 5 10:47:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> * ruby_atomic.h (ATOMIC_PTR_EXCHANGE): atomic exchange function for @@ -187,8 +187,6 @@ with all sufficient information, see the ChangeLog file. * ObjectSpace.allocation_method_id * ObjectSpace.allocation_generation * ObjectSpace.reachable_objects_from_root - * ObjectSpace.after_gc_start_hook= - * ObjectSpace.after_gc_end_hook= * ObjectSpace.dump * ObjectSpace.dump_all diff --git a/ext/-test-/tracepoint/tracepoint.c b/ext/-test-/tracepoint/tracepoint.c index ebe2996622..208bf57a47 100644 --- a/ext/-test-/tracepoint/tracepoint.c +++ b/ext/-test-/tracepoint/tracepoint.c @@ -5,7 +5,8 @@ struct tracepoint_track { size_t newobj_count; size_t free_count; size_t gc_start_count; - size_t gc_end_count; + size_t gc_end_mark_count; + size_t gc_end_sweep_count; size_t objects_count; VALUE objects[10]; }; @@ -37,9 +38,14 @@ tracepoint_track_objspace_events_i(VALUE tpval, void *data) track->gc_start_count++; break; } - case RUBY_INTERNAL_EVENT_GC_END: + case RUBY_INTERNAL_EVENT_GC_END_MARK: { - track->gc_end_count++; + track->gc_end_mark_count++; + break; + } + case RUBY_INTERNAL_EVENT_GC_END_SWEEP: + { + track->gc_end_sweep_count++; break; } default: @@ -52,7 +58,8 @@ tracepoint_track_objspace_events(VALUE self) { struct tracepoint_track track = {0, 0, 0, 0, 0,}; VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_INTERNAL_EVENT_FREEOBJ | - RUBY_INTERNAL_EVENT_GC_START | RUBY_INTERNAL_EVENT_GC_END, + RUBY_INTERNAL_EVENT_GC_START | RUBY_INTERNAL_EVENT_GC_END_MARK | + RUBY_INTERNAL_EVENT_GC_END_SWEEP, tracepoint_track_objspace_events_i, &track); VALUE result = rb_ary_new(); @@ -63,7 +70,8 @@ tracepoint_track_objspace_events(VALUE self) rb_ary_push(result, SIZET2NUM(track.newobj_count)); rb_ary_push(result, SIZET2NUM(track.free_count)); rb_ary_push(result, SIZET2NUM(track.gc_start_count)); - rb_ary_push(result, SIZET2NUM(track.gc_end_count)); + rb_ary_push(result, SIZET2NUM(track.gc_end_mark_count)); + rb_ary_push(result, SIZET2NUM(track.gc_end_sweep_count)); rb_ary_cat(result, track.objects, track.objects_count); return result; diff --git a/ext/objspace/gc_hook.c b/ext/objspace/gc_hook.c index cf3dc0cc9d..eb6ac7401a 100644 --- a/ext/objspace/gc_hook.c +++ b/ext/objspace/gc_hook.c @@ -88,16 +88,8 @@ set_after_gc_start(VALUE rb_mObjSpace, VALUE proc) "__set_after_gc_start_tpval__", "__set_after_gc_start_proc__"); } -static VALUE -set_after_gc_end(VALUE rb_mObjSpace, VALUE proc) -{ - return set_gc_hook(rb_mObjSpace, proc, RUBY_INTERNAL_EVENT_GC_END, - "__set_after_gc_end_tpval__", "__set_after_gc_end_proc__"); -} - void Init_gc_hook(VALUE rb_mObjSpace) { rb_define_module_function(rb_mObjSpace, "after_gc_start_hook=", set_after_gc_start, 1); - rb_define_module_function(rb_mObjSpace, "after_gc_end_hook=", set_after_gc_end, 1); } @@ -2954,7 +2954,7 @@ gc_after_sweep(rb_objspace_t *objspace) } #endif - gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END, 0 /* TODO: pass minor/immediate flag? */); + gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END_SWEEP, 0); } static int @@ -4122,7 +4122,7 @@ gc_marks_body(rb_objspace_t *objspace, int full_mark) gc_mark_roots(objspace, full_mark, 0); gc_mark_stacked_objects(objspace); - /* cleanup */ + gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END_MARK, 0); rgengc_report(1, objspace, "gc_marks_body: end (%s)\n", full_mark ? "full" : "minor"); } diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index b2ec3d61ff..05c53fb838 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1712,15 +1712,16 @@ int ruby_native_thread_p(void); #define RUBY_EVENT_COVERAGE 0x020000 /* internal events */ -#define RUBY_INTERNAL_EVENT_SWITCH 0x040000 -#define RUBY_EVENT_SWITCH 0x040000 /* obsolete name. this macro is for compatibility */ - /* 0x080000 */ -#define RUBY_INTERNAL_EVENT_NEWOBJ 0x100000 -#define RUBY_INTERNAL_EVENT_FREEOBJ 0x200000 -#define RUBY_INTERNAL_EVENT_GC_START 0x400000 -#define RUBY_INTERNAL_EVENT_GC_END 0x800000 -#define RUBY_INTERNAL_EVENT_OBJSPACE_MASK 0xf00000 -#define RUBY_INTERNAL_EVENT_MASK 0xfffe0000 +#define RUBY_INTERNAL_EVENT_SWITCH 0x040000 +#define RUBY_EVENT_SWITCH 0x040000 /* obsolete name. this macro is for compatibility */ + /* 0x080000 */ +#define RUBY_INTERNAL_EVENT_NEWOBJ 0x100000 +#define RUBY_INTERNAL_EVENT_FREEOBJ 0x200000 +#define RUBY_INTERNAL_EVENT_GC_START 0x400000 +#define RUBY_INTERNAL_EVENT_GC_END_MARK 0x800000 +#define RUBY_INTERNAL_EVENT_GC_END_SWEEP 0x1000000 +#define RUBY_INTERNAL_EVENT_OBJSPACE_MASK 0x1f00000 +#define RUBY_INTERNAL_EVENT_MASK 0xfffe0000 typedef unsigned long rb_event_flag_t; typedef void (*rb_event_hook_func_t)(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass); diff --git a/test/-ext-/tracepoint/test_tracepoint.rb b/test/-ext-/tracepoint/test_tracepoint.rb index 27fcceceb5..9743a15510 100644 --- a/test/-ext-/tracepoint/test_tracepoint.rb +++ b/test/-ext-/tracepoint/test_tracepoint.rb @@ -17,13 +17,14 @@ class TestTracepointObj < Test::Unit::TestCase nil } - newobj_count, free_count, gc_start_count, gc_end_count, *newobjs = *result + newobj_count, free_count, gc_start_count, gc_end_mark_count, gc_end_sweep_count, *newobjs = *result assert_equal 2, newobj_count assert_equal 2, newobjs.size assert_equal 'foobar', newobjs[0] assert_equal Object, newobjs[1].class assert_operator free_count, :>=, 0 - assert_operator gc_start_count, :>=, gc_end_count + assert_operator gc_start_count, :==, gc_end_mark_count + assert_operator gc_start_count, :>=, gc_end_sweep_count end def test_tracks_objspace_count @@ -39,7 +40,7 @@ class TestTracepointObj < Test::Unit::TestCase GC.stat(stat2) GC.enable - newobj_count, free_count, gc_start_count, gc_end_count, *_newobjs = *result + newobj_count, free_count, gc_start_count, gc_end_mark_count, gc_end_sweep_count, *newobjs = *result assert_operator stat2[:total_allocated_object] - stat1[:total_allocated_object], :>=, newobj_count assert_operator 1_000_000, :<=, newobj_count @@ -47,8 +48,9 @@ class TestTracepointObj < Test::Unit::TestCase assert_operator stat2[:total_freed_object] + stat2[:heap_final_slot] - stat1[:total_freed_object], :>=, free_count assert_operator stat2[:count] - stat1[:count], :==, gc_start_count - assert_operator gc_start_count, :>=, gc_end_count - assert_operator stat2[:count] - stat1[:count] - 1, :<=, gc_end_count + assert_operator gc_start_count, :==, gc_end_mark_count + assert_operator gc_start_count, :>=, gc_end_sweep_count + assert_operator stat2[:count] - stat1[:count] - 1, :<=, gc_end_sweep_count end def test_tracepoint_specify_normal_and_internal_events |