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:
parent
1546ffed49
commit
9d64a54209
6 changed files with 23 additions and 59 deletions
6
eval.c
6
eval.c
|
@ -560,11 +560,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag != TAG_FATAL) {
|
if (tag != TAG_FATAL) {
|
||||||
if (RUBY_DTRACE_RAISE_ENABLED()) {
|
RUBY_DTRACE_HOOK(RAISE, rb_obj_classname(th->errinfo));
|
||||||
RUBY_DTRACE_RAISE(rb_obj_classname(th->errinfo),
|
|
||||||
rb_sourcefile(),
|
|
||||||
rb_sourceline());
|
|
||||||
}
|
|
||||||
EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->cfp->self, 0, 0, mesg);
|
EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->cfp->self, 0, 0, mesg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
gc.c
18
gc.c
|
@ -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
|
static inline void
|
||||||
gc_prof_mark_timer_start(rb_objspace_t *objspace)
|
gc_prof_mark_timer_start(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
if (RUBY_DTRACE_GC_MARK_BEGIN_ENABLED()) {
|
RUBY_DTRACE_GC_HOOK(MARK_BEGIN);
|
||||||
RUBY_DTRACE_GC_MARK_BEGIN();
|
|
||||||
}
|
|
||||||
#if GC_PROFILE_MORE_DETAIL
|
#if GC_PROFILE_MORE_DETAIL
|
||||||
if (gc_prof_enabled(objspace)) {
|
if (gc_prof_enabled(objspace)) {
|
||||||
gc_prof_record(objspace)->gc_mark_time = getrusage_time();
|
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
|
static inline void
|
||||||
gc_prof_mark_timer_stop(rb_objspace_t *objspace)
|
gc_prof_mark_timer_stop(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
if (RUBY_DTRACE_GC_MARK_END_ENABLED()) {
|
RUBY_DTRACE_GC_HOOK(MARK_END);
|
||||||
RUBY_DTRACE_GC_MARK_END();
|
|
||||||
}
|
|
||||||
#if GC_PROFILE_MORE_DETAIL
|
#if GC_PROFILE_MORE_DETAIL
|
||||||
if (gc_prof_enabled(objspace)) {
|
if (gc_prof_enabled(objspace)) {
|
||||||
gc_profile_record *record = gc_prof_record(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
|
static inline void
|
||||||
gc_prof_sweep_timer_start(rb_objspace_t *objspace)
|
gc_prof_sweep_timer_start(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
if (RUBY_DTRACE_GC_SWEEP_BEGIN_ENABLED()) {
|
RUBY_DTRACE_GC_HOOK(SWEEP_BEGIN);
|
||||||
RUBY_DTRACE_GC_SWEEP_BEGIN();
|
|
||||||
}
|
|
||||||
if (gc_prof_enabled(objspace)) {
|
if (gc_prof_enabled(objspace)) {
|
||||||
gc_profile_record *record = gc_prof_record(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
|
static inline void
|
||||||
gc_prof_sweep_timer_stop(rb_objspace_t *objspace)
|
gc_prof_sweep_timer_stop(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
if (RUBY_DTRACE_GC_SWEEP_END_ENABLED()) {
|
RUBY_DTRACE_GC_HOOK(SWEEP_END);
|
||||||
RUBY_DTRACE_GC_SWEEP_END();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gc_prof_enabled(objspace)) {
|
if (gc_prof_enabled(objspace)) {
|
||||||
double sweep_time;
|
double sweep_time;
|
||||||
|
|
|
@ -1341,12 +1341,14 @@ VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0)
|
||||||
RUBY_SYMBOL_EXPORT_END
|
RUBY_SYMBOL_EXPORT_END
|
||||||
|
|
||||||
#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
|
#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
|
||||||
|
RUBY_DTRACE_HOOK(name##_CREATE, arg)
|
||||||
|
#define RUBY_DTRACE_HOOK(name, arg) \
|
||||||
do { \
|
do { \
|
||||||
if (UNLIKELY(RUBY_DTRACE_##name##_CREATE_ENABLED())) { \
|
if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
|
||||||
int dtrace_line; \
|
int dtrace_line; \
|
||||||
const char *dtrace_file = rb_source_loc(&dtrace_line); \
|
const char *dtrace_file = rb_source_loc(&dtrace_line); \
|
||||||
if (!dtrace_file) dtrace_file = ""; \
|
if (!dtrace_file) dtrace_file = ""; \
|
||||||
RUBY_DTRACE_##name##_CREATE(arg, dtrace_file, dtrace_line); \
|
RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
36
load.c
36
load.c
|
@ -698,11 +698,7 @@ rb_f_load(int argc, VALUE *argv)
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "11", &fname, &wrap);
|
rb_scan_args(argc, argv, "11", &fname, &wrap);
|
||||||
|
|
||||||
if (RUBY_DTRACE_LOAD_ENTRY_ENABLED()) {
|
RUBY_DTRACE_HOOK(LOAD_ENTRY, StringValuePtr(fname));
|
||||||
RUBY_DTRACE_LOAD_ENTRY(StringValuePtr(fname),
|
|
||||||
rb_sourcefile(),
|
|
||||||
rb_sourceline());
|
|
||||||
}
|
|
||||||
|
|
||||||
orig_fname = FilePathValue(fname);
|
orig_fname = FilePathValue(fname);
|
||||||
fname = rb_str_encode_ospath(orig_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));
|
rb_load_internal(path, RTEST(wrap));
|
||||||
|
|
||||||
if (RUBY_DTRACE_LOAD_RETURN_ENABLED()) {
|
RUBY_DTRACE_HOOK(LOAD_RETURN, StringValuePtr(fname));
|
||||||
RUBY_DTRACE_LOAD_RETURN(StringValuePtr(fname),
|
|
||||||
rb_sourcefile(),
|
|
||||||
rb_sourceline());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
|
@ -967,11 +959,7 @@ rb_require_internal(VALUE fname, int safe)
|
||||||
} volatile saved;
|
} volatile saved;
|
||||||
char *volatile ftptr = 0;
|
char *volatile ftptr = 0;
|
||||||
|
|
||||||
if (RUBY_DTRACE_REQUIRE_ENTRY_ENABLED()) {
|
RUBY_DTRACE_HOOK(REQUIRE_ENTRY, StringValuePtr(fname));
|
||||||
RUBY_DTRACE_REQUIRE_ENTRY(StringValuePtr(fname),
|
|
||||||
rb_sourcefile(),
|
|
||||||
rb_sourceline());
|
|
||||||
}
|
|
||||||
|
|
||||||
TH_PUSH_TAG(th);
|
TH_PUSH_TAG(th);
|
||||||
saved.safe = rb_safe_level();
|
saved.safe = rb_safe_level();
|
||||||
|
@ -984,20 +972,12 @@ rb_require_internal(VALUE fname, int safe)
|
||||||
FilePathValue(fname);
|
FilePathValue(fname);
|
||||||
rb_set_safe_level_force(0);
|
rb_set_safe_level_force(0);
|
||||||
|
|
||||||
if (RUBY_DTRACE_FIND_REQUIRE_ENTRY_ENABLED()) {
|
RUBY_DTRACE_HOOK(FIND_REQUIRE_ENTRY, StringValuePtr(fname));
|
||||||
RUBY_DTRACE_FIND_REQUIRE_ENTRY(StringValuePtr(fname),
|
|
||||||
rb_sourcefile(),
|
|
||||||
rb_sourceline());
|
|
||||||
}
|
|
||||||
|
|
||||||
path = rb_str_encode_ospath(fname);
|
path = rb_str_encode_ospath(fname);
|
||||||
found = search_required(path, &path, safe);
|
found = search_required(path, &path, safe);
|
||||||
|
|
||||||
if (RUBY_DTRACE_FIND_REQUIRE_RETURN_ENABLED()) {
|
RUBY_DTRACE_HOOK(FIND_REQUIRE_RETURN, StringValuePtr(fname));
|
||||||
RUBY_DTRACE_FIND_REQUIRE_RETURN(StringValuePtr(fname),
|
|
||||||
rb_sourcefile(),
|
|
||||||
rb_sourceline());
|
|
||||||
}
|
|
||||||
if (found) {
|
if (found) {
|
||||||
if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
|
if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
|
||||||
result = 0;
|
result = 0;
|
||||||
|
@ -1036,11 +1016,7 @@ rb_require_internal(VALUE fname, int safe)
|
||||||
|
|
||||||
th->errinfo = errinfo;
|
th->errinfo = errinfo;
|
||||||
|
|
||||||
if (RUBY_DTRACE_REQUIRE_RETURN_ENABLED()) {
|
RUBY_DTRACE_HOOK(REQUIRE_RETURN, StringValuePtr(fname));
|
||||||
RUBY_DTRACE_REQUIRE_RETURN(StringValuePtr(fname),
|
|
||||||
rb_sourcefile(),
|
|
||||||
rb_sourceline());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
12
parse.y
12
parse.y
|
@ -5520,17 +5520,15 @@ yycompile0(VALUE arg)
|
||||||
parser->token_info_enabled = !compile_for_eval && RTEST(ruby_verbose);
|
parser->token_info_enabled = !compile_for_eval && RTEST(ruby_verbose);
|
||||||
#endif
|
#endif
|
||||||
#ifndef RIPPER
|
#ifndef RIPPER
|
||||||
if (RUBY_DTRACE_PARSE_BEGIN_ENABLED()) {
|
#define RUBY_DTRACE_PARSE_HOOK(name) \
|
||||||
RUBY_DTRACE_PARSE_BEGIN(ruby_sourcefile,
|
if (RUBY_DTRACE_PARSE_##name##_ENABLED()) { \
|
||||||
ruby_sourceline);
|
RUBY_DTRACE_PARSE_##name(ruby_sourcefile, ruby_sourceline); \
|
||||||
}
|
}
|
||||||
|
RUBY_DTRACE_PARSE_HOOK(BEGIN);
|
||||||
#endif
|
#endif
|
||||||
n = yyparse((void*)parser);
|
n = yyparse((void*)parser);
|
||||||
#ifndef RIPPER
|
#ifndef RIPPER
|
||||||
if (RUBY_DTRACE_PARSE_END_ENABLED()) {
|
RUBY_DTRACE_PARSE_HOOK(END);
|
||||||
RUBY_DTRACE_PARSE_END(ruby_sourcefile,
|
|
||||||
ruby_sourceline);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
ruby_debug_lines = 0;
|
ruby_debug_lines = 0;
|
||||||
ruby_coverage = 0;
|
ruby_coverage = 0;
|
||||||
|
|
|
@ -85,9 +85,7 @@ rb_clear_method_cache_by_class(VALUE klass)
|
||||||
if (klass && klass != Qundef) {
|
if (klass && klass != Qundef) {
|
||||||
int global = klass == rb_cBasicObject || klass == rb_cObject || klass == rb_mKernel;
|
int global = klass == rb_cBasicObject || klass == rb_cObject || klass == rb_mKernel;
|
||||||
|
|
||||||
if (RUBY_DTRACE_METHOD_CACHE_CLEAR_ENABLED()) {
|
RUBY_DTRACE_HOOK(METHOD_CACHE_CLEAR, (global ? "global" : rb_class2name(klass)));
|
||||||
RUBY_DTRACE_METHOD_CACHE_CLEAR(global ? "global" : rb_class2name(klass), rb_sourcefile(), rb_sourceline());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (global) {
|
if (global) {
|
||||||
INC_GLOBAL_METHOD_STATE();
|
INC_GLOBAL_METHOD_STATE();
|
||||||
|
|
Loading…
Reference in a new issue