Created
October 15, 2013 20:37
-
-
Save tenderlove/6998277 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/probes.d b/probes.d | |
index dd7a7bf..e077bd8 100644 | |
--- a/probes.d | |
+++ b/probes.d | |
@@ -214,6 +214,16 @@ provider ruby { | |
Fired at the end of a sweep phase. | |
*/ | |
probe gc__sweep__end(); | |
+ | |
+ /* | |
+ ruby:::method-cache-clear(filename, lineno); | |
+ | |
+ This probe is fired when the method cache is cleared. | |
+ | |
+ * `filename` the file name where the cache is _being cleared_ (a string) | |
+ * `lineno` the line number where the cache is _being cleared_ (an int) | |
+ */ | |
+ probe method__cache__clear(const char *filename, int lineno); | |
}; | |
#pragma D attributes Stable/Evolving/Common provider ruby provider | |
diff --git a/vm_method.c b/vm_method.c | |
index 0066c17..0be118f 100644 | |
--- a/vm_method.c | |
+++ b/vm_method.c | |
@@ -47,6 +47,9 @@ void | |
rb_clear_cache(void) | |
{ | |
INC_VM_STATE_VERSION(); | |
+ if (RUBY_DTRACE_METHOD_CACHE_CLEAR_ENABLED()) { | |
+ RUBY_DTRACE_METHOD_CACHE_CLEAR(rb_sourcefile(), rb_sourceline()); | |
+ } | |
} | |
void | |
@@ -54,10 +57,13 @@ rb_clear_cache_by_class(VALUE klass) | |
{ | |
if (klass && klass != Qundef) { | |
if (klass == rb_cBasicObject || klass == rb_cObject || klass == rb_mKernel) { | |
- INC_VM_STATE_VERSION(); | |
+ rb_clear_cache(); | |
} | |
else { | |
rb_class_clear_method_cache(klass); | |
+ if (RUBY_DTRACE_METHOD_CACHE_CLEAR_ENABLED()) { | |
+ RUBY_DTRACE_METHOD_CACHE_CLEAR(rb_sourcefile(), rb_sourceline()); | |
+ } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment