1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

internal.h: RUBY_DTRACE_HOOK

* internal.h (RUBY_DTRACE_HOOK): extract from
  RUBY_DTRACE_CREATE_HOOK for other type hooks.

* gc.c (RUBY_DTRACE_GC_HOOK): ditto.

* parse.y (RUBY_DTRACE_PARSE_HOOK): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-10-31 01:02:29 +00:00
parent 1546ffed49
commit 9d64a54209
6 changed files with 23 additions and 59 deletions

6
eval.c
View file

@ -560,11 +560,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
}
if (tag != TAG_FATAL) {
if (RUBY_DTRACE_RAISE_ENABLED()) {
RUBY_DTRACE_RAISE(rb_obj_classname(th->errinfo),
rb_sourcefile(),
rb_sourceline());
}
RUBY_DTRACE_HOOK(RAISE, rb_obj_classname(th->errinfo));
EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->cfp->self, 0, 0, mesg);
}
}

18
gc.c
View file

@ -8414,12 +8414,12 @@ gc_prof_timer_stop(rb_objspace_t *objspace)
}
}
#define RUBY_DTRACE_GC_HOOK(name) \
do {if (RUBY_DTRACE_GC_##name##_ENABLED()) RUBY_DTRACE_GC_##name();} while (0)
static inline void
gc_prof_mark_timer_start(rb_objspace_t *objspace)
{
if (RUBY_DTRACE_GC_MARK_BEGIN_ENABLED()) {
RUBY_DTRACE_GC_MARK_BEGIN();
}
RUBY_DTRACE_GC_HOOK(MARK_BEGIN);
#if GC_PROFILE_MORE_DETAIL
if (gc_prof_enabled(objspace)) {
gc_prof_record(objspace)->gc_mark_time = getrusage_time();
@ -8430,9 +8430,7 @@ gc_prof_mark_timer_start(rb_objspace_t *objspace)
static inline void
gc_prof_mark_timer_stop(rb_objspace_t *objspace)
{
if (RUBY_DTRACE_GC_MARK_END_ENABLED()) {
RUBY_DTRACE_GC_MARK_END();
}
RUBY_DTRACE_GC_HOOK(MARK_END);
#if GC_PROFILE_MORE_DETAIL
if (gc_prof_enabled(objspace)) {
gc_profile_record *record = gc_prof_record(objspace);
@ -8444,9 +8442,7 @@ gc_prof_mark_timer_stop(rb_objspace_t *objspace)
static inline void
gc_prof_sweep_timer_start(rb_objspace_t *objspace)
{
if (RUBY_DTRACE_GC_SWEEP_BEGIN_ENABLED()) {
RUBY_DTRACE_GC_SWEEP_BEGIN();
}
RUBY_DTRACE_GC_HOOK(SWEEP_BEGIN);
if (gc_prof_enabled(objspace)) {
gc_profile_record *record = gc_prof_record(objspace);
@ -8459,9 +8455,7 @@ gc_prof_sweep_timer_start(rb_objspace_t *objspace)
static inline void
gc_prof_sweep_timer_stop(rb_objspace_t *objspace)
{
if (RUBY_DTRACE_GC_SWEEP_END_ENABLED()) {
RUBY_DTRACE_GC_SWEEP_END();
}
RUBY_DTRACE_GC_HOOK(SWEEP_END);
if (gc_prof_enabled(objspace)) {
double sweep_time;

View file

@ -1341,12 +1341,14 @@ VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0)
RUBY_SYMBOL_EXPORT_END
#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
RUBY_DTRACE_HOOK(name##_CREATE, arg)
#define RUBY_DTRACE_HOOK(name, arg) \
do { \
if (UNLIKELY(RUBY_DTRACE_##name##_CREATE_ENABLED())) { \
if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
int dtrace_line; \
const char *dtrace_file = rb_source_loc(&dtrace_line); \
if (!dtrace_file) dtrace_file = ""; \
RUBY_DTRACE_##name##_CREATE(arg, dtrace_file, dtrace_line); \
RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \
} \
} while (0)

36
load.c
View file

@ -698,11 +698,7 @@ rb_f_load(int argc, VALUE *argv)
rb_scan_args(argc, argv, "11", &fname, &wrap);
if (RUBY_DTRACE_LOAD_ENTRY_ENABLED()) {
RUBY_DTRACE_LOAD_ENTRY(StringValuePtr(fname),
rb_sourcefile(),
rb_sourceline());
}
RUBY_DTRACE_HOOK(LOAD_ENTRY, StringValuePtr(fname));
orig_fname = FilePathValue(fname);
fname = rb_str_encode_ospath(orig_fname);
@ -714,11 +710,7 @@ rb_f_load(int argc, VALUE *argv)
}
rb_load_internal(path, RTEST(wrap));
if (RUBY_DTRACE_LOAD_RETURN_ENABLED()) {
RUBY_DTRACE_LOAD_RETURN(StringValuePtr(fname),
rb_sourcefile(),
rb_sourceline());
}
RUBY_DTRACE_HOOK(LOAD_RETURN, StringValuePtr(fname));
return Qtrue;
}
@ -967,11 +959,7 @@ rb_require_internal(VALUE fname, int safe)
} volatile saved;
char *volatile ftptr = 0;
if (RUBY_DTRACE_REQUIRE_ENTRY_ENABLED()) {
RUBY_DTRACE_REQUIRE_ENTRY(StringValuePtr(fname),
rb_sourcefile(),
rb_sourceline());
}
RUBY_DTRACE_HOOK(REQUIRE_ENTRY, StringValuePtr(fname));
TH_PUSH_TAG(th);
saved.safe = rb_safe_level();
@ -984,20 +972,12 @@ rb_require_internal(VALUE fname, int safe)
FilePathValue(fname);
rb_set_safe_level_force(0);
if (RUBY_DTRACE_FIND_REQUIRE_ENTRY_ENABLED()) {
RUBY_DTRACE_FIND_REQUIRE_ENTRY(StringValuePtr(fname),
rb_sourcefile(),
rb_sourceline());
}
RUBY_DTRACE_HOOK(FIND_REQUIRE_ENTRY, StringValuePtr(fname));
path = rb_str_encode_ospath(fname);
found = search_required(path, &path, safe);
if (RUBY_DTRACE_FIND_REQUIRE_RETURN_ENABLED()) {
RUBY_DTRACE_FIND_REQUIRE_RETURN(StringValuePtr(fname),
rb_sourcefile(),
rb_sourceline());
}
RUBY_DTRACE_HOOK(FIND_REQUIRE_RETURN, StringValuePtr(fname));
if (found) {
if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
result = 0;
@ -1036,11 +1016,7 @@ rb_require_internal(VALUE fname, int safe)
th->errinfo = errinfo;
if (RUBY_DTRACE_REQUIRE_RETURN_ENABLED()) {
RUBY_DTRACE_REQUIRE_RETURN(StringValuePtr(fname),
rb_sourcefile(),
rb_sourceline());
}
RUBY_DTRACE_HOOK(REQUIRE_RETURN, StringValuePtr(fname));
return result;
}

12
parse.y
View file

@ -5520,17 +5520,15 @@ yycompile0(VALUE arg)
parser->token_info_enabled = !compile_for_eval && RTEST(ruby_verbose);
#endif
#ifndef RIPPER
if (RUBY_DTRACE_PARSE_BEGIN_ENABLED()) {
RUBY_DTRACE_PARSE_BEGIN(ruby_sourcefile,
ruby_sourceline);
#define RUBY_DTRACE_PARSE_HOOK(name) \
if (RUBY_DTRACE_PARSE_##name##_ENABLED()) { \
RUBY_DTRACE_PARSE_##name(ruby_sourcefile, ruby_sourceline); \
}
RUBY_DTRACE_PARSE_HOOK(BEGIN);
#endif
n = yyparse((void*)parser);
#ifndef RIPPER
if (RUBY_DTRACE_PARSE_END_ENABLED()) {
RUBY_DTRACE_PARSE_END(ruby_sourcefile,
ruby_sourceline);
}
RUBY_DTRACE_PARSE_HOOK(END);
#endif
ruby_debug_lines = 0;
ruby_coverage = 0;

View file

@ -85,9 +85,7 @@ rb_clear_method_cache_by_class(VALUE klass)
if (klass && klass != Qundef) {
int global = klass == rb_cBasicObject || klass == rb_cObject || klass == rb_mKernel;
if (RUBY_DTRACE_METHOD_CACHE_CLEAR_ENABLED()) {
RUBY_DTRACE_METHOD_CACHE_CLEAR(global ? "global" : rb_class2name(klass), rb_sourcefile(), rb_sourceline());
}
RUBY_DTRACE_HOOK(METHOD_CACHE_CLEAR, (global ? "global" : rb_class2name(klass)));
if (global) {
INC_GLOBAL_METHOD_STATE();