[前][次][番号順一覧][スレッド一覧]

ruby-changes:40318

From: nobu <ko1@a...>
Date: Sat, 31 Oct 2015 10:02:52 +0900 (JST)
Subject: [ruby-changes:40318] nobu:r52399 (trunk): internal.h: RUBY_DTRACE_HOOK

nobu	2015-10-31 10:02:29 +0900 (Sat, 31 Oct 2015)

  New Revision: 52399

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52399

  Log:
    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.

  Modified files:
    trunk/eval.c
    trunk/gc.c
    trunk/internal.h
    trunk/load.c
    trunk/parse.y
    trunk/vm_method.c
Index: load.c
===================================================================
--- load.c	(revision 52398)
+++ load.c	(revision 52399)
@@ -698,11 +698,7 @@ rb_f_load(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/load.c#L698
 
     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) https://github.com/ruby/ruby/blob/trunk/load.c#L710
     }
     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 saf https://github.com/ruby/ruby/blob/trunk/load.c#L959
     } 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 saf https://github.com/ruby/ruby/blob/trunk/load.c#L972
 	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 saf https://github.com/ruby/ruby/blob/trunk/load.c#L1016
 
     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;
 }
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 52398)
+++ vm_method.c	(revision 52399)
@@ -85,9 +85,7 @@ rb_clear_method_cache_by_class(VALUE kla https://github.com/ruby/ruby/blob/trunk/vm_method.c#L85
     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();
Index: eval.c
===================================================================
--- eval.c	(revision 52398)
+++ eval.c	(revision 52399)
@@ -560,11 +560,7 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L560
     }
 
     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);
     }
 }
Index: gc.c
===================================================================
--- gc.c	(revision 52398)
+++ gc.c	(revision 52399)
@@ -8414,12 +8414,12 @@ gc_prof_timer_stop(rb_objspace_t *objspa https://github.com/ruby/ruby/blob/trunk/gc.c#L8414
     }
 }
 
+#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 * https://github.com/ruby/ruby/blob/trunk/gc.c#L8430
 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 *o https://github.com/ruby/ruby/blob/trunk/gc.c#L8442
 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 https://github.com/ruby/ruby/blob/trunk/gc.c#L8455
 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;
Index: parse.y
===================================================================
--- parse.y	(revision 52398)
+++ parse.y	(revision 52399)
@@ -5520,17 +5520,15 @@ yycompile0(VALUE arg) https://github.com/ruby/ruby/blob/trunk/parse.y#L5520
     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;
Index: internal.h
===================================================================
--- internal.h	(revision 52398)
+++ internal.h	(revision 52399)
@@ -1341,12 +1341,14 @@ VALUE rb_imemo_new(enum imemo_type type, https://github.com/ruby/ruby/blob/trunk/internal.h#L1341
 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)
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]