Project

General

Profile

Feature #14813 ยป 0001-gc.c-make-gc_enter-gc_exit-pairs-dtrace-probes-too.patch

normalperson (Eric Wong), 06/02/2018 02:05 PM

View differences:

gc.c
2926 2926
    rb_objspace_call_finalizer(&rb_objspace);
2927 2927
}
2928 2928

  
2929
enum gc_event {
2930
    gc_ev_SWEEP_CONTINUE = 0,
2931
    gc_ev_MARKS_CONTINUE,
2932
    gc_ev_START,
2933
    gc_ev_REST,
2934
    gc_ev_RB_OBJSPACE_CALL_FINALIZER
2935
};
2936

  
2937
static const char * const
2938
gc_event_str[] = {
2939
    "sweep_continue",
2940
    "marks_continue",
2941
    "gc_start",
2942
    "gc_rest",
2943
    "rb_objspace_call_finalizer"
2944
};
2945

  
2946
#define RUBY_DTRACE_GC_HOOK(name) \
2947
    do {if (RUBY_DTRACE_GC_##name##_ENABLED()) RUBY_DTRACE_GC_##name();} while (0)
2948

  
2949
#define GC_ENTER(objspace, event) do { \
2950
	RUBY_DTRACE_GC_HOOK(event##_ENTER); \
2951
	gc_enter(objspace, gc_event_str[gc_ev_##event]); \
2952
} while (0)
2953

  
2954
#define GC_EXIT(objspace, event) do { \
2955
	RUBY_DTRACE_GC_HOOK(event##_EXIT); \
2956
	gc_exit(objspace, gc_event_str[gc_ev_##event]); \
2957
} while (0)
2958

  
2929 2959
static void
2930 2960
rb_objspace_call_finalizer(rb_objspace_t *objspace)
2931 2961
{
......
2962 2992
    dont_gc = 1;
2963 2993

  
2964 2994
    /* running data/file finalizers are part of garbage collection */
2965
    gc_enter(objspace, "rb_objspace_call_finalizer");
2995
    GC_ENTER(objspace, RB_OBJSPACE_CALL_FINALIZER);
2966 2996

  
2967 2997
    /* run data/file object's finalizers */
2968 2998
    for (i = 0; i < heap_allocated_pages; i++) {
......
2995 3025
	}
2996 3026
    }
2997 3027

  
2998
    gc_exit(objspace, "rb_objspace_call_finalizer");
3028
    GC_EXIT(objspace, RB_OBJSPACE_CALL_FINALIZER);
2999 3029

  
3000 3030
    if (heap_pages_deferred_final) {
3001 3031
	finalize_list(objspace, heap_pages_deferred_final);
......
3768 3798
{
3769 3799
    GC_ASSERT(dont_gc == FALSE);
3770 3800

  
3771
    gc_enter(objspace, "sweep_continue");
3801
    GC_ENTER(objspace, SWEEP_CONTINUE);
3772 3802
#if USE_RGENGC
3773 3803
    if (objspace->rgengc.need_major_gc == GPR_FLAG_NONE && heap_increment(objspace, heap)) {
3774 3804
	gc_report(3, objspace, "gc_sweep_continue: success heap_increment().\n");
3775 3805
    }
3776 3806
#endif
3777 3807
    gc_sweep_step(objspace, heap);
3778
    gc_exit(objspace, "sweep_continue");
3808
    GC_EXIT(objspace, SWEEP_CONTINUE);
3779 3809
}
3780 3810
#endif
3781 3811

  
......
5668 5698

  
5669 5699
    GC_ASSERT(dont_gc == FALSE);
5670 5700

  
5671
    gc_enter(objspace, "marks_continue");
5701
    GC_ENTER(objspace, MARKS_CONTINUE);
5672 5702

  
5673 5703
    PUSH_MARK_FUNC_DATA(NULL);
5674 5704
    {
......
5695 5725
    }
5696 5726
    POP_MARK_FUNC_DATA();
5697 5727

  
5698
    gc_exit(objspace, "marks_continue");
5728
    GC_EXIT(objspace, MARKS_CONTINUE);
5699 5729
}
5700 5730
#endif
5701 5731

  
......
6427 6457
    gc_verify_internal_consistency(Qnil);
6428 6458
#endif
6429 6459

  
6430
    gc_enter(objspace, "gc_start");
6460
    GC_ENTER(objspace, START);
6431 6461

  
6432 6462
    if (ruby_gc_stressful) {
6433 6463
	int flag = FIXNUM_P(ruby_gc_stress_mode) ? FIX2INT(ruby_gc_stress_mode) : 0;
......
6492 6522
    }
6493 6523
    gc_prof_timer_stop(objspace);
6494 6524

  
6495
    gc_exit(objspace, "gc_start");
6525
    GC_EXIT(objspace, START);
6496 6526
    return TRUE;
6497 6527
}
6498 6528

  
......
6503 6533
    int sweeping = is_lazy_sweeping(heap_eden);
6504 6534

  
6505 6535
    if (marking || sweeping) {
6506
	gc_enter(objspace, "gc_rest");
6536
	GC_ENTER(objspace, REST);
6507 6537

  
6508 6538
	if (RGENGC_CHECK_MODE >= 2) gc_verify_internal_consistency(Qnil);
6509 6539

  
......
6515 6545
	if (is_lazy_sweeping(heap_eden)) {
6516 6546
	    gc_sweep_rest(objspace);
6517 6547
	}
6518
	gc_exit(objspace, "gc_rest");
6548
	GC_EXIT(objspace, REST);
6519 6549
    }
6520 6550
}
6521 6551

  
......
8740 8770
    }
8741 8771
}
8742 8772

  
8743
#define RUBY_DTRACE_GC_HOOK(name) \
8744
    do {if (RUBY_DTRACE_GC_##name##_ENABLED()) RUBY_DTRACE_GC_##name();} while (0)
8745 8773
static inline void
8746 8774
gc_prof_mark_timer_start(rb_objspace_t *objspace)
8747 8775
{
probes.d
215 215
  */
216 216
  probe gc__sweep__end();
217 217

  
218

  
219
  probe gc__sweep__continue__enter();
220
  probe gc__sweep__continue__exit();
221
  probe gc__marks__continue__enter();
222
  probe gc__marks__continue__exit();
223
  probe gc__start__enter();
224
  probe gc__start__exit();
225
  probe gc__rest__enter();
226
  probe gc__rest__exit();
227
  probe gc__rb__objspace__call__finalizer__enter();
228
  probe gc__rb__objspace__call__finalizer__exit();
229

  
218 230
  /*
219 231
     ruby:::method-cache-clear(class, filename, lineno);
220 232

  
221
-